-
Notifications
You must be signed in to change notification settings - Fork 0
PHP Templates
PHP templates is the classic view template method supported since Joomla! 1.5. You can freely mix HTML and PHP to fine-tune the display of your view.
You should remember that this file is actually included by the view class. This means that $this
is a reference to the View object and you have access to all of its public and protected methods and properties.
Unlike Joomla!, you MUST NEVER use include
or require
to load a subtemplate. You can load any template from inside another template using the loadAnyTemplate
method of the View class. Unlike include
or require
, loadAnyTemplate
will honour Joomla! version suffixes and Joomla! template overrides.
$this->loadAnyTemplate('auto:com_example/Item/default_price');
This URI-like construct tells FOF where to look for your template file.
The schema (the part up to and including :
) tells FOF which part of the application to look in:
-
site:
Look in the frontend only -
admin:
Look in the backend only -
auto:
Look in the backend if we're running inside a backend application, otherwise look in the frontend -
any:
Look in both the frontend and backend. First we'll look inside the backend and then in the frontend if we're running inside a backend application, otherwise we will first look in the frontend and then in the backend.
The rest of this URI is the component name, view name and layout separated by forward slashes.
You must NOT specify the extension of the view template to load. FOF will automatically look for both classic PHP and Blade templates.
You cannot load XML forms using loadAnyTemplate
. You also cannot load a form defined for another component, view or layout. What we're about to describe applies if you have both an XML form and a classic PHP view template for the same layout. For example, if you have both a default.php
and a form.default.xml
file for the same view.
Use the code
<?php echo $this->getRenderedForm(); ?>
to insert the XML form, rendered as HTML, anywhere you want in your classic PHP view template.
This construct allows you to customise the layout (e.g. adding information before/after the form) while still using the XML file to render the actual form.
You will have to do an escape to PHP. For example:
<?php Container::getInstance('com_other', array(
'tempInstance' => true,
'input' => array(
'view' => 'something',
'task' => 'whatever',
'other_something_id' => $this->item->other_something_id
)))->dispatcher->dispatch(); ?>
FOF (Framework on Framework) and its documentation are Copyright © 2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd.
FOF is Open Source Software, distributed under the GNU General Public License, version 2 of the license, or (at your option) any later version.
The FOF Wiki content is provided under the GNU Free Documentation License, version 1.3 of the license, or (at your option) any later version.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found on the GNU site.