Jump to content

Add Custom Page Error 404


Recommended Posts

3 hours ago, jayashanka said:

Hi All,

I have tried to add a custom page using a custom module. But it gives a 404 error. I couldn't find any issue or error log.

Appreciate if you could help on this.

I have attached custom module file here for your kind reference.

customservices.zip 2.02 kB · 0 downloads

Follow below code 

create a new page following the next steps:

Create the controller: /controllers/front/MyPageController.php

<?php

class MyPageControllerCore extends FrontController {

      public $php_self = 'mypage';

      public $ssl = true;

      public function initContent() {

          parent::initContent();

         $this->setTemplate('mypage');

    }

}

Create the tpl file in your theme: /themes/YOUR_THEME/templates/mypage.tpl

{extends file='page.tpl'}

{block name='page_header_container'}

{/block}

{block name='page_content'}

   PAGE CONTENT HERE

{/block}

Delete the cache /var/cache/dev/ and /var/cache/prod/

How to access it: http://your-site.com/index.php?controller=mypage

  • Thanks 1
  • Confused 1
Link to comment
Share on other sites

6 hours ago, rthakur said:

Follow below code 

create a new page following the next steps:

Create the controller: /controllers/front/MyPageController.php

<?php

class MyPageControllerCore extends FrontController {

      public $php_self = 'mypage';

      public $ssl = true;

      public function initContent() {

          parent::initContent();

         $this->setTemplate('mypage');

    }

}

Create the tpl file in your theme: /themes/YOUR_THEME/templates/mypage.tpl

{extends file='page.tpl'}

{block name='page_header_container'}

{/block}

{block name='page_content'}

   PAGE CONTENT HERE

{/block}

Delete the cache /var/cache/dev/ and /var/cache/prod/

How to access it: http://your-site.com/index.php?controller=mypage

@rthakur thank you for sharing this code. It works. Only issue is using controller parameter in URL. if we can set routing and make URL short, this works well. I would like to know if this is possible. 

Link to comment
Share on other sites

11 hours ago, ps8moduly.cz said:

I'm glad I helped. You can rename the page in the seo & URL settings.

Thank you, I have added it to SEO & URLs. 

And then I tried to add this page to front office main menu from "Configure Main Menu" like below.

image.thumb.png.d6562587cdfa42728134b853cfa346eb.png

 

And then like below,

 

image.thumb.png.16f9b5ca5edd659babebcfc6f7388555.png

 

But About Us menu item is not appearing in Main Menu. Any reason for this?

 

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...