[TYPO3-mvc] UriBuilder with realurl in CLI mode

Sebastian Schreiber me at schreibersebastian.de
Mon Aug 8 13:26:31 CEST 2011


Am 08.08.2011 13:04, schrieb Franz Koch:
> Hey Michael,
>
>> I have a problem using the uri builder in an extbase controller I 
>> call from CLI. The controller is called via normal bootstrap stuff 
>> and the TS config for the FE of the website is loaded correctly 
>> already. The problem is, the uri builder does not care about realurl 
>> settings and returns a (relative) url with normal parameters.
>>
>> The code looks like this:
>>
>> $this->uriBuilder->setCreateAbsoluteUri(true);
>> $this->uriBuilder->setTargetPageUid(123);
>> $this->uriBuilder->setArguments(array('xxx' =>  yyy));
>> $this->uriBuilder->buildFrontendUri();
>>
>> Creates something like: ?id=123&xxx=yyy&cHash=xyz
>> Should be like this: http://www.myDomain.de/de/my-page-name/xxx/yyy.html
>>
>> Does anybody know how to get the uri builder to use realurl settings 
>> in such a scenario?
>
> The UriBuilder is internally using typolink to build the uris - so if 
> realUrl is not triggered in your case, I suppose your CLI context is 
> most likely missing some TSFE stuff needed to get realURL working 
> (don't ask me what exactly though).
>
Hi Michael,
have a look at the extension pagepath from Dimitry Dulepov.
Writing a simple viewhelper for the backend should be a piece of cake.

Maybe this is a beginning for you:

class Tx_SschFluidExtbaseHelper_ViewHelpers_Be_Link_PagePathViewHelper 
extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {

     /**
      * Get the fullpath to a fe-page from backend. Used with the 
extension pagepath from Dimitry Dulepov
      * @param integer $pageId
      * @param array $parameters
      * @return mixed
      */
     public function render($pageId = NULL, $parameters = array()) {
         if (t3lib_extMgm::isLoaded('pagepath')) {
             require_once(t3lib_extMgm::extPath('pagepath', 
'class.tx_pagepath_api.php'));
             if (NULL === $pageId) {
                 $pageId = $this->renderChildren();
             }
             return tx_pagepath_api::getPagePath($pageId, $parameters);
         }
         return;
     }
}

-- 
Sebastian Schreiber
(Medieninformatiker B.Sc.)
(TYPO3 Certified Integrator)

Schanzenstraße 27, Schlosserei 4
D-51063 Köln

T  0221 677 88 541
M  0176 431 05 790

Skype schreibersebastian.de

me at schreibersebastian.de
www.schreibersebastian.de

Steuernummer: 217 / 5269 / 4675



More information about the TYPO3-project-typo3v4mvc mailing list