TYPO3 decode realurl in userfunc

眉间皱痕 提交于 2020-01-03 06:32:05

问题


I have made an userFunc to make nice urls in my own extension.

How do I decode the urls so that TYPO3 will show the right product?

I think that the uid of the product will be somewhere so that I can use it.

Am I right?


回答1:


If I remember correctly, you don't have to decode anything. RealURL sets the $_GET variables back to what they would be if RealURL wasn't used. So if your URL contains...

&tx_origkentaurproducts_kentaurproductsfe[action]=show

...and RealURL transforms it for example to...

/action/show

...then when such URL is being displayed, you should still have your data available in...

$_GET['tx_origkentaurproducts_kentaurproductsfe']['action']



回答2:


This is how things look at our projects:

function main($params, $ref) {
    if ($params['decodeAlias']) {
        return $this->alias2id($params['value']);
    } else {
        return $this->id2alias($params['value']);
    }
}

So do whatever your alias2id needs to do. Maybe add the uid in the URL as a part. So you have something like productname-productcolor-productsize-2938202 as your segment. Explode the segment by '-' and pop it off your array and return it. Might save you a SQL query as well.



来源:https://stackoverflow.com/questions/19909340/typo3-decode-realurl-in-userfunc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!