Jump to content

Front Controller Module url rewrite problem


andref

Recommended Posts

Hello there, I'm making a module to add a custom page to my store, I've got the module and page working as I want with url_rewrite disabled. But I want to use friendly url's, for this I activated them and added the page in BO->SEO&URLS with title and rewrite slug, but it's not working, I get a 404 error and the url changes. I tried a bunch of direferent things and research for hours online, so this is my last hope. (Just to mention, I got the page working before activating the friendly url's)

 

Now some code; I'm using PrestaShop 1.6

 

Module PHP file:

<?php
  if (!defined('_PS_VERSION_')) {

    exit;
  }

  class InCustomPages extends Module
  {

    public function __construct()
    {
      $this->name = 'incustompages';
      $this->tab = 'front_office_features';
      $this->version = '1.0.0';
      $this->author = 'Andre Forte';
      $this->need_instance = 0;
      $this->ps_version_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
      $this->bootstrap = true;

      parent::__construct();

      $this->displayName = $this->l('In Custom Pages');
      $this->description = $this->l('Custom Pages for SempreIn.');

      $this->confirmationUninstall = $this->l('Are you sure you want to uninstall?');
    }

    public function install() {

      if (!parent::install())
			   return false;
      return true;
    }

    public function uninstall() {

      if (!parent::uninstall())
  		  return false;
  		return true;
    }

  }

My Controller PHP:

<?php

class incustompagesNewsletterModuleFrontController extends ModuleFrontController
{

  public $php_self = 'newsletter';

  public function init() {

    $this->page_name = 'newsletter';
    $this->display_column_left = false;
    parent::init();
  }

  public function initContent() {

    parent::initContent();

    $this->setTemplate('newsletter.tpl');
  }

  public function setMedia() {

    parent::setMedia();
    $this->addCSS(__PS_BASE_URI__.'modules/'.$this->module->name.'/css/'.$this->module->name.'.css');
  }

}

I've added the page in BO->SEO & URLs with proper title and url rewrite "newsletter"

 

The url should work like www.mysite.com/newsletter

 

But it doesn't, I get a 404 error and the url changes to www.mysite.com/index.php?controller=newsletter&module=incustompages

 

I hope I was clear on my problem and hope someone can help me out.

Thank you in advance!

Link to comment
Share on other sites

  • 1 year later...
  • 11 months later...
On 10/19/2016 at 5:41 PM, andref said:

That did it!

When we think we're doind the right thing and it just isn't needed...  :)

Thank you so much!

what did it?

for the love of all things, please include how you fixed it?

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...