TYPO3 decode realurl in userfunc

2019-06-14 16:25发布

问题:

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.



标签: typo3 realurl