LostKobrakai Posted September 10, 2014 Posted September 10, 2014 I'm trying to dynamicly replace the url of products, if they are shown in a category context, so the url does reflect the correct path with the category included. But the url won't be replaced, while I can set a random new variable to the product pages. for ($i=0; $i < count($products); $i++) { $products->eq($i)->of(false); $products->eq($i)->random = "hi$i"; $products->eq($i)->url = "url"; var_dump($products->eq($i)->random, $products->eq($i)->url); $products->eq($i)->of(true); } This returns: string(27) "/shop/produkte/testprodukt/", string(3) "hi0"[/size].
Soma Posted September 10, 2014 Posted September 10, 2014 url is a method and not a property. You'd need to hook Page:path to change url. 1
Nico Knoll Posted September 10, 2014 Posted September 10, 2014 Or do a simple workaround: for ($i=0; $i < count($products); $i++) { // define a placeholder $products->eq($i)->link = $products->eq($i)->url; $products->eq($i)->of(false); $products->eq($i)->random = "hi$i"; // if you want to change the url you can now do it as simple as: $products->eq($i)->link = "url"; var_dump($products->eq($i)->random, $products->eq($i)->link); $products->eq($i)->of(true); } // now go out and use "link" instead of "url"
LostKobrakai Posted September 10, 2014 Author Posted September 10, 2014 That's exactly what I did now. In the relavent templates I just call this, to get the changed value. $page->get("link|url"); I used this to have a two way url structure for categorized content: "…/articles/articlename/" and "…/category/categoryname/articlename/". Thinking about writing a short tutorial for this. 1
mel47 Posted October 26, 2016 Posted October 26, 2016 Hi Seems awkward to answer a so old post, but since I don't know what exactly searching for, I found this one with the exact same goal : adding category in the url. Unfortunately, I'm not sure to understand what to do. @LostKobrakai, by any chance, did you wrote this tutorial? Thanks Mélanie
LostKobrakai Posted October 26, 2016 Author Posted October 26, 2016 I think this is what you're looking for: 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now