carbotex Posted January 6, 2015 Share Posted January 6, 2015 Hi, I'm using Prestashop 1.6 and am trying to create a custom module with custom frontcontroller. I was able to dig around the forum to get it working, however I can't figure out how to create a friendly URL. Currently I have to use this format to access my controller index.php?fc=module&module=test&controller=display Is there a way to create friendly-url to something like the following: /module-test-display I went to the BO, under SEO and friendly URL, I can't see the page that I created with my custom module. How do I make the my custom module page appear in here? Thanks, -wa Link to comment Share on other sites More sharing options...
Richard S Posted January 6, 2015 Share Posted January 6, 2015 Make sure your controller has parameter class MyController extends Controller { public $php_self = 'yourcontrollername'; } Link to comment Share on other sites More sharing options...
vekia Posted January 6, 2015 Share Posted January 6, 2015 it should extend other class class YourModuleNameControllerNameModuleFrontController extends ModuleFrontController{ } Is there a way to create friendly-url to something like the following: it is, under preferences > seo & urls add your new controller and generate friendly-url for it Link to comment Share on other sites More sharing options...
carbotex Posted January 7, 2015 Author Share Posted January 7, 2015 (edited) it should extend other class class YourModuleNameControllerNameModuleFrontController extends ModuleFrontController{ } it is, under preferences > seo & urls add your new controller and generate friendly-url for it I'm using ModuleFrontController, I can access my module with this path. Note fc parameter has to be the last one, otherwise it will not work. index.php?controller=sampah&module=thxslide&fc=module <== Works index.php?fc=module&controller=sampah&module=thxslide <== 404 How do I add my new controller in order for me to generate friendly-url? When I click the Page dropdown, under the Module Pages section, I do not see my controller? Below is what I have so far, did I miss anything? /modules/thxslide/thxslide.php <?php if (!defined('_PS_VERSION_')) exit; class ThxSlide extends Module { public function __construct() { $this->name = 'thxslide'; $this->tab = 'front_office_features'; $this->version = '1.0.0'; $this->author = 'Author'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->controllers = array('sampah'); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('THX slide'); $this->description = $this->l('Description of my module.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('thxslide')) $this->warning = $this->l('No name provided'); } } /modules/thxslide/controllers/front/sampah.php <?php class ThxSlideSampahModuleFrontController extends ModuleFrontController { public $php_self = "Sampah"; public function __construct() { parent::__construct(); $this->context = Context::getContext(); } /** * Initialize sampah controller */ public function init() { parent::init(); $this->display_column_left = false; $this->display_column_right = false; } /** * Set default media for this controller */ public function setMedia() { parent::setMedia(); $this->addJS(_THEME_JS_DIR_.'sampah.js'); $this->addCSS(_THEME_CSS_DIR_.'sampah.css'); } public function initContent() { parent::initContent(); $this->context->smarty->assign(array( 'path' => 'sampah', )); $this->setTemplate('sampah.tpl'); } } /modules/thxslide/views/templates/front/sampah.tpl <h2>Sampah Controller</h2> Edited January 7, 2015 by carbotex (see edit history) Link to comment Share on other sites More sharing options...
Richard S Posted January 7, 2015 Share Posted January 7, 2015 Yes, the class was different, it was just an example. Everything should work fine now and you should see your controller in SEO URLs section. If not, try to make that "Sampah" to "sampah" Link to comment Share on other sites More sharing options...
carbotex Posted January 7, 2015 Author Share Posted January 7, 2015 Thanks Richard, I tried that already, it doesn't make any difference Link to comment Share on other sites More sharing options...
carbotex Posted January 8, 2015 Author Share Posted January 8, 2015 Any idea why it is not showing even after I follow the guidelines? Any help will be greatly appreciated ... -wa Link to comment Share on other sites More sharing options...
carbotex Posted January 11, 2015 Author Share Posted January 11, 2015 Would it be possible if I can get a simple template which is already proven to work on your end? The module zip file would be great. Link to comment Share on other sites More sharing options...
Azoda.net Posted January 19, 2015 Share Posted January 19, 2015 i have same as your problem do you have solved it yet ? Link to comment Share on other sites More sharing options...
wayann Posted January 24, 2015 Share Posted January 24, 2015 (edited) nvm please mod delete this post Edited January 24, 2015 by wayann (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts