prestatent Posted May 21, 2015 Share Posted May 21, 2015 PS 1.6.0.8 Hi I've created a new module using the PS documentation. All works ok. Now I want to take this further and display a different template depending on the URL input. I know I can pass a key in the URL and then code for the value in the module controller to show a different template based on the key, but this means I have to show the key in the URL. I can create a new URL by going to BO->Preferences->SEO & URLs and select the module from the list only once. Is there any way to select add in the same module more than once, but give it a different rewrite-url? Basically, I'm trying to get away from creating the same module three times but calling a different template for each one and have a different URL. Thanks for any help. Link to comment Share on other sites More sharing options...
cristic Posted May 21, 2015 Share Posted May 21, 2015 Use $_SERVER['REQUEST_URI'] to get the current page URL. From here, you can determine what template to display. Link to comment Share on other sites More sharing options...
prestatent Posted May 21, 2015 Author Share Posted May 21, 2015 (edited) Thanks for your answer but I'm unsure how this would solve my issue. - I have one module - my rewrite URL is setup in BO->Preferences->SEO & URLs. I've called it "segment". - The three links on my homepage are: www.mysite.com/segment-test1 - should show template 1 www.mysite.com/segment-test2 - should show template 2 www.mysite.com/segment-test3 - should show template 3 What I want to do is show in the address bar is either www.mysite.com/segment-test1 OR www.mysite.com/segment-test2 OR www.mysite.com/segment-test3 and show the correct template. As these URL's don't actually exist I would get a 404. However I can only have one URL which would be www.mysite.com/segment, as this is what is setup in BO->Preferences->SEO & URLs. I don't want to go down the route of modifying the .htaccess file manually since this could be overwritten if I regenerate it. All I'm looking for is a tidy UR. Edited May 21, 2015 by prestatent (see edit history) Link to comment Share on other sites More sharing options...
prestatent Posted May 21, 2015 Author Share Posted May 21, 2015 What would be good if I could set up multiple SEO & URL's links which all point to the same module, Unfortunately this does not seem to be possible once the module is already added. Link to comment Share on other sites More sharing options...
cristic Posted May 21, 2015 Share Posted May 21, 2015 I believe .htaccess is the solution here. Prestashop is regenerating .htaccess only between # ~~start~~ and # ~~end~~ blocks. So if you place your rules before # ~~start~~, it will stay there and will work correct. 1 Link to comment Share on other sites More sharing options...
prestatent Posted May 21, 2015 Author Share Posted May 21, 2015 Thanks Cristic. I didn't know that. I'll give it a try. Cheers Link to comment Share on other sites More sharing options...
prestatent Posted May 21, 2015 Author Share Posted May 21, 2015 Just one additional clarification on this. Is there any reason that a module cannot have multiple url-rewrite within BO->Preferences->SEO & URLs? Link to comment Share on other sites More sharing options...
prestatent Posted May 22, 2015 Author Share Posted May 22, 2015 Does anyone know how I could set this up. Can't seem to get the url working after editing the .htaccess file. My module is located in www.mysite.com/modules/althome and is based on the PS documentation on how to create a module. Has anyone created a new module before and then created a rewrite in the .htaccess file? The rule in my .htaccess file is: RewriteRule ^testmod$ %{ENV:REWRITEBASE}module/althome/display?page=$1 Link to comment Share on other sites More sharing options...
prestatent Posted May 24, 2015 Author Share Posted May 24, 2015 Anyone has some ideas how to achieve this? Link to comment Share on other sites More sharing options...
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