0

I've been looking for the way to convert the typo3 internal urls whose format is t3://page?uid=xx to a human readable url http://mydomain/page-slug.

I'd want to do the same thing that the ViewHelper link.typolink does but in the php context (outside of the Extbase context, I'm not in a controller). The context is that I am gettind a link from a db to send it to an external API. I tried to look for documentation but all helpers are about generating an url from controller name and action, etc...

Can somebody please explain what is the proper way to do it? The typo3 version I use is the 11.5.

Thanks for your answers.

onizukaek
  • 1,082
  • 1
  • 14
  • 38
  • Seems not the clean way but it could be a workaround: instantiate a cObject and use `stdWrap.typolink` – Julian Hofmann Dec 04 '22 at 13:28
  • @Julian Hoffman Thanks for the hint, I tried your workaround, but not sure if I really did what you ment, i injected the cObject in my service, then I called the method $this->cObj->stdWrap_typolink('t3://page?uid=xx') but I still get the typolink as an output – onizukaek Dec 04 '22 at 16:16
  • The first parameter of `stdWrap_typolink()` is 'content', on which the link would be generated. You need to fill in the second one, the 'conf'. This conf-array should look like `['parameter' => 't3://page?uid=xx', 'returnLast' => true]`. Might be, you have to set a non-empty 'content' also first param, too. – Julian Hofmann Dec 04 '22 at 18:47

1 Answers1

1

Actually a content was needed but I had no clue which value to set in it and... I found it, in the cObject, there is the method

typoLink_URL($conf)

That takes the same parameter as stdWrap_typolink, calls the typolink method as well but with the $content variable already set which in this case is a pipe |.

So you only need to call it so:

$this->cObj->typoLink_URL(['parameter' => $typoLink]);

And you have your url.

Thank you for your help Julian.

onizukaek
  • 1,082
  • 1
  • 14
  • 38