German Greek English Spanish French Italian
menu

Page generators and templates : Blog

Page generators are optional parts of a template which allows you to fully customize the contents, layout and style of a web page. Blog

Inicio/ Blog/ Page generators and templates

Page generators and templates

Page generators in Elxis 5.6
Page generators in Elxis 5.6

Although Elxis has many parameters to customize the layout and style of a page, sometimes this is not enough. There are cases we need customization beyond the standard options. This is why page generators introduced in Elxis 5.6. A Page generator is a custom block of code that generates the HTML of the page instead of the built-in component. This allows us to achieve 100% customization of the web page contents, layout and style. Page Generators are optional parts of a template. For now, page generators are available in component Content for Category pages, Articles, Tags page and the Archive page. On each category/article you can select (or not) a page generator (if available on your template). Category A may have a totally different style of category B, while category C might have the Elxis default style.

If you have a template named supercool page generators should be located under this path: templates/supercool/generators/. Page generators are php files and have special naming depending on their type. For instance page generators for categories must start with category_. For articles with article_ and for tags and archive the name is standard (content_tags and content_archive respectively). Sample generators for template supercool follows.

  • templates/supercool/generators/category_Blog.php
  • templates/supercool/generators/category_Blog2.php
  • templates/supercool/generators/category_List.php
  • templates/supercool/generators/article_presentation.php
  • templates/supercool/generators/article_tourism.php
  • templates/supercool/generators/content_tags.php
  • templates/supercool/generators/content_archive.php

When you edit a category you can select as generator: Component Content (Elxis default), Blog, Blog2 or List. When you edit an article you can select as generator: Component Content (Elxis default), presentation or tourism. If you change the template and the selected generator does not exist in the new template the page will be generated by component Content (fallback process).

Select page generator for a category
Select page generator for a category

Instructions for developers

Create an empty php file, name it and place it as the instructions given above. Open the file for editing. If it is for articles open the corresponding Elxis file to have it as a guide, components/com_content/views/article.html.php. Inside the Elxis file there is a method named showArticle. This is where Elxis constructs the HTML of an article. Inside your PHP file you must mimic this method but you are free to modify it as you wish. You can create a totally different layout, use your own CSS classes, your own javascript, add forms and galleries without using plugins, you can even enrich the contents of the article with additional content. You are free to create something totally custom for any purpose you like. While working inside your PHP file you have all the power of Elxis CMS which you can use directly. For instance add a style-sheet file in page headers, use the elxisForm library, etc. When you are ready go to Elxis administration, click to add or edit an article, and on the parameters tab you will notice that your new page generator is available as an option. If you select it the HTML of that specific article will be generated by your PHP file.

The same principle applies for categories (file category.html.php method showCategory), tags and archive pages. Please use the Elxis forums for additional help.

Artículo siguiente
Open Shop 3.9