Reputation: 1508
I'm using prestashop 1.6. In my home page I have some images linking to product details on click. I set the home page template to point to destination pages using absolute urls (eg. https://www.example.com/presta/1-my-product). But what if my domain name will change? What if the path change? I should change all the links in my site.. this is not scalable.. So I was wondering if is it possible to link subsections (like products) with relative urls? In the documentation I can't find nothing but it's such a basilar feature..
Upvotes: 0
Views: 582
Reputation: 538
Instead of using absolute link you have to use this in your controller
$my_product_link = $this->context->link->getPageLink("product", true, (int)$this->context->language->id, array("id", <your product id>));
$this->context->smarty->assign(
array(
'my_product_link' => $my_product_link
)
);
and then use the link in your tpl template like this
<a href="{$my_product_link}">something</a>
What i worte is:
1) Retrieve the correct product url in your controller
2) Pass the variable to your template
3) Display the variable in your template
Upvotes: 0