Jump to content

creating a custom dynamic page: how to implement dynamic url?


rajlaskar

Recommended Posts

Hi

 

I am creating a custom dynamic page, depending on get value on url the page content will change
 
I have done everything and everything seems working fine: created a module, controller , query into category to get products, displayed them properly, created seo URL and the new page is showing perfectly as

localhost/prestashop/cl
 
what I want is
 
localhost/prestashop/cl-iphone-accessories-2
localhost/prestashop/cl-samsung-smart-phone-accessories-3
 
 
depending on pid 2, 3 page content will change, how to create such the URL? , rest query and all i will do, depending on  (int)Tools::getValue('pid')
 
Thank you
Edited by rajlaskar (see edit history)
Link to comment
Share on other sites

You mean, how to redirect to that controller passing in a custom parameter? From a template or php file?

php: $this->context->link->getModuleLink('modulename', 'controllername', array('pid' => 1));
tpl: {$link->getModuleLink('modulename', 'controllername', ['pid' => 1])}

Link to comment
Share on other sites

Thank you Nemo, for your reply.

 

i get the proper result by such url localhost/prestashop/cl?pid=1 , but i want friendly url format like

localhost/prestashop/cl-iphone-accessories-1 

 

i want to make it friendly url, shall i directly add url redirect code on .httaccess?

Link to comment
Share on other sites

no, it will be automated if you use that syntax I mentioned above

Hi

 

H really appreciate your reply, as i said i already have created this new custom page, and it works like that - from my module backend you will create a new page [not cms page] and enter page details  -  auto generated page id ,name , url-key, mention which categories to show in that page by comma separation, and when view this page localhost/prestashop/cl-iphone-accessories-1  with will show product from the page id 1 , querying into those category for page 1 and in carousel [this has already beed done]
 
rest everything has already been done products are showing properly when viewed like this 

 

localhost/prestashop/cl?pid=1 
localhost/prestashop/cl?pid=2
 
 
but i want SE froendly URL like

 

localhost/prestashop/cl-iphone-accessories-1
localhost/prestashop/cl-samsung-smart-phone-accessories-2
 
these url i will put in my menu to open that URL
Link to comment
Share on other sites

×
×
  • Create New...