简体   繁体   English

触发Typo3 realurl扩展以通过PHP代码生成URL

[英]Trigger Typo3 realurl extension to generate url via PHP code

Knows someone a way to trigger realurl Typo3 extension to trigger the generation of urls? 知道有人可以触发realurl Typo3扩展名来触发URL生成的方法吗? Some like 有些像

Pseudo code: realurl->generateUrl($page_uid); 伪代码:realurl-> generateUrl($ page_uid);

We use the extension in a setup and it works great in the frontend, but because we access some page via restler extension, we need the urls directly in the tx_realurl_pathdata. 我们在安装程序中使用了扩展名,并且在前端工作得很好,但是由于我们通过Restler扩展名访问某些页面,因此我们需要直接在tx_realurl_pathdata中的url。

We tried the way to typolink_URL but for some reason the realurl didn't worked here. 我们尝试了键入typolink_URL的方法,但是由于某种原因,realurl在这里不起作用。

In the frontend context you can simply use ContentObjectRenderer::typoLink_URL() which will automatically invoke RealURL to build a human readable URL. 在前端上下文中,您可以简单地使用ContentObjectRenderer::typoLink_URL() ,它将自动调用RealURL来构建人类可读的URL。

In the backend context you'll have to instantiate quite a few dummy objects to get closer to frontend URLs. 在后端上下文中,您必须实例化许多虚拟对象才能更接近前端URL。 Most of the time you'll run typoLink_URL() and fix errors one by one. 大多数情况下,您将运行typoLink_URL()并一一修复错误。 You can also have a look at what TYPO3 does to handle regular frontend requests . 您还可以查看TYPO3如何处理常规前端请求 Various extensions for redirects already do something like this, eg my_redirects . 重定向的各种扩展已经做了类似的事情,例如my_redirects

An easier solution to all of this would be the pagepath extension which defers URL generation. 解决所有这些问题的一个更简单的解决方案是推迟URL生成的pagepath扩展。 Of course, you won't get nice URLs immediately, only after a redirect. 当然,只有重定向后,您才能立即获得漂亮的URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM