Reputation: 729
I'm just learning about joomla coding. In http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Example_of_a_frontend_update_function I see a reference $this->form, see also copied code below.
My beginners question: To what does $this relate?
code site/views/updhelloworld/tmpl/default.php:
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.tooltip');
?>
<h2>Update the Hello World greeting</h2>
<form class="form-validate" action="<?php echo JRoute::_('index.php'); ?>" method="post" id="updhelloworld" name="updhelloworld">
<fieldset>
<dl>
<dt><?php echo $this->form->getLabel('id'); ?></dt>
<dd><?php echo $this->form->getInput('id'); ?></dd>
Upvotes: 0
Views: 67
Reputation: 7034
$this
in the Joomla templates (views) is refering to the JView
class.
The JView
class has a lot of standard option which it comes with, and can be found in the documentation you have given. In addition, one can add a view that extends JView
so, the method/properties there will be available in the template via $this
too.
http://docs.joomla.org/J2.5:Developing_a_MVC_Component/Adding_a_view_to_the_site_part
Following that documentation you can see how the controller renders a view, and how a custom view class can be done.
The exact answer of your question is there too:
This template file will be included by the JView class. Therefore, here, $this refers to the HelloWorldViewHelloWorld class.
Upvotes: 0
Reputation: 720
$this-> is a context from Joomla.
It is included somewhere, so $this is referenced to the class where the file gets included.
In this, it will be a context of the current page, which is build as a class.
Upvotes: 0