Creating Static Pages - kulbakin/anahita GitHub Wiki
Introduction
The HTML component (com_html) allows your to create static webpages utilizing your own html, php, css and javascript code making it a very easy to create custom pages exact to your needs.
Basics
The default location for com_html pages is in the Shiraz template folder. This can be changed in the HTML – Configurations page under Extend, then HTML.
Browse to the content folder within the com_html folder. Create a file here called hello.php. Edit it and enter in the following
<?php defined('KOOWA') or die('Restricted access') ?>
This adds a bit of security to your php files and prevents someone from accessing them directly.
To set the title of the page and optionally its meta description, we can use the following helper functions:
<?php @title('Hello!'); ?>
<?php @description('Sample page example'); ?>
And finally add this to the page:
<?php echo "Hello World!"; ?>
Save the file and load your instillation. Click on Hello in the menu and view your new static web page!
More advanced examples of what you can do with com_html can be found in the examples folder. Most notably changing view template
<?php @service('application.dispatcher')->getRequest()->tmpl = 'component' ?>
Linking Static Pages
Static pages can be accessed using such url pattern http://SITEDOMAIN/html/FILENAME (filename without extention). To compose such urls from PHP code you con use
JRoute::_('option=com_html&layout=FILENAME');
or using template helper
<?php echo @route('option=com_html&layout=FILENAME') ?>
Create Menu Link (optional)
Log in to the Administration section of your site. In the menu, hover over Menus and then click Menu Manager. Click New in the top right. Click on Html in the Menu Item Type selection. It will expand and then click on Content. This will open the New Menu Item form.
In the Title field enter Hello and underneath Parameters – Basic, enter hello in the Page field. Click Save in the top right.