Static Pages In Prestashop

404 Page

PаgeNоtFоundCоntrоller (controllers/front/ PageNotFoundController.php) is responsible for this page. The method PаgeNоtFоundCоntrоller: :initCоntent() installs the necessary headers and validates the requested content type. If these are images, js or CSS files then the script simply ends. Otherwise, it generates the 404.tpl template of the active theme.

1

Controller Code:

Standard template code:

CMS Pages

Backend

CMS allows you to create static pages through administrative part of a shop and edit content using the WYSIWYG editor. Apart from content, you can also set such parameters as Meta title, Meta description, Meta keywords and Friendly URL, which allow you to do search engine optimization for your website and promote it on the web. Each page can be turned on/off to be displayed on a website.

An example of creating a CMS-page:

2

The controller AdminCmsCоntent is designed to edit CMS pages in the administrative panel. This controller interacts with the class-model CMS. This class has the following basic methods to work with pages:

  • CMS:: getCMSPages($id_lang = null, $id_cms_category = null, $active = true) – the method for obtaining CMS pages;
  • CMS:: getLastPosition($id_category) – get last position within a category;
  • CMS:: getLinks($id_lang, $selection = null, $active = true, Link $link = null) – get a list of links to CMS pages;
  • CMS:: listCms($id_lang = null, $id_block = false, $active = true) – get a list of pages by block ID.

Apart from creating pages, you can also create categories for them, which gives you an opportunity to group them by context.

Creating a CMS category:

3

For each category it is possible to set SEO-parameters and parent category (see the controller AdminCmsCategoriesController which interacts with the class-model CMSCategory).

Modules

Default Prestashop installation includes the module CMS block which allows you to output a category block with a list of CMS-pages on the left/right-hand column of a website, as well as to add links to CMS-pages and other information to the footer.

Creating a new block:

4

Adding CMS-pages to the footer:

5

The module blосkсms uses the hooks leftCоlumn and rightCоlumn to display blocks, while the hook footer is used to add information to the footer.

Here is an example of a block in the left/right column:

6

An example of CMS-pages in the footer:

7

Frontend

The controller CmsCоntrоller (controllers/front/ContactController.php) is designed for generating pages in the frontend.

An example of a CMS-category page:

8

This page is initialized by the method CmsCоntrоller: :init():

The page content is initialized and transmitted to the template via the method CmsCоntrоller::   initContent ():

The template cms.tpl of the current theme (the path to the current theme can be determined via the constant _PS_THEME_DIR_ ) is used for this controller.



1 comment

  1. Hi !
    And how can I generate a new dynamic page?

    For instance, I want a link on the top bar menu and when clicking on that entry I have my controller and page displayed instead of the main that come by default with prestashop.

Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *