Monday, October 18, 2010

Using JPane and laoding templates from within a template

Well, let us assume our template is called form.php. My template holds this code to create a pane and to display some content in the pane:
<?php
jimport('joomla.html.pane');

/* creating the pane */
$pane =& JPane::getInstance('tabs'); // change "tabs" to "sliders" or other way round to get the different behaviour

/* creating a content area */
echo $pane->startPane("somecontent-area");

echo $pane->startPanel("panel-name-one","panel1_id");
echo $this->loadTemplate("some-content");
echo $pane->endPanel();

echo $pane->startPanel("panel-name-two","panel2_id");
echo "some content for panel two";
echo $pane->endPanel();

echo $pane->endPane();
?>



The "difficult" thing to remember is, if you want to load a template from within a template... your template to be loaded has to be named like "your-current-template"_"template-to-be-loaded.php"

e.g.


my current template is called form.php
the template to be loaded is form_some-content.php

I load it in form.php by calling 

Code:
echo $this->loadTemplate("some-content");

in the above example

Hope this helped someone,

No comments:

Post a Comment