Hi there,
I thought a snippets thread with many small code examples of specific problems would come handy for many developers out there starting with Joomla 1.5 development.
So, don't let discuss us here but post snippets new or collected ones from the forums !
PLEASE DISCUSS ABOUT THIS THREAD IN ANOTHER THREAD, THIS ONE SHOULD BE ONLY FOR POSTING CODE.
Thanx in advance,
Alex
The J!1.5 Code Snippets / CookBook Thread
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
-
- Joomla! Apprentice
- Posts: 16
- Joined: Wed Aug 22, 2007 8:41 am
- Location: Germany
- Contact:
-
- Joomla! Apprentice
- Posts: 16
- Joined: Wed Aug 22, 2007 8:41 am
- Location: Germany
- Contact:
Re: The J!1.5 Code Snippets / CookBook Thread
Using JHTML to display calendar input , dates etc:
When I looked through the joomla api reference to implement a calendar input field, I was wondering how I could do that 'cause in the joomla source code I found JTHML:_(bla bla) all over the place.. but the API reference told me something different about the usage of JHTML. However, after talking with people from the J!101-SkypeChat I got the answer. Here's the snippet to create a calendar input field in your template / form:
Using this way, you can use the other methods of JHTML as well. Have a look at this api doc for further information: http://api.joomla.org/svn/Joomla-Framework/HTML/JHTML.html#calendar
thanx to Ian MacLennan from J101 Chat
Bye, Alex
When I looked through the joomla api reference to implement a calendar input field, I was wondering how I could do that 'cause in the joomla source code I found JTHML:_(bla bla) all over the place.. but the API reference told me something different about the usage of JHTML. However, after talking with people from the J!101-SkypeChat I got the answer. Here's the snippet to create a calendar input field in your template / form:
Code: Select all
<?php echo JHTML::_( 'calendar',$value,$name,$id); ?>
Using this way, you can use the other methods of JHTML as well. Have a look at this api doc for further information: http://api.joomla.org/svn/Joomla-Framework/HTML/JHTML.html#calendar
thanx to Ian MacLennan from J101 Chat
Bye, Alex
o
-
- Joomla! Apprentice
- Posts: 16
- Joined: Wed Aug 22, 2007 8:41 am
- Location: Germany
- Contact:
Re: The J!1.5 Code Snippets / CookBook Thread
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:
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
in the above example
Hope this helped someone,
bye Alex
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:
Code: Select all
<?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: Select all
echo $this->loadTemplate("some-content");
in the above example
Hope this helped someone,
bye Alex
o
-
- Joomla! Apprentice
- Posts: 16
- Joined: Wed Aug 22, 2007 8:41 am
- Location: Germany
- Contact:
Re: The J!1.5 Code Snippets / CookBook Thread
Using JButton in your component:
Here's a small snippet for using JButton and it's derived classes in your component.
Here's a small snippet for using JButton and it's derived classes in your component.
Code: Select all
<?php
jimport('joomla.html.toolbar.button.popup');
// creating a popup button, however the menus etd are still getting displayed in the menu (how can we change that??)
$popupbutton = new JButtonPopup();
echo $popupbutton->fetchButton( $type='Popup', $name = 'some-popup-button', $text = 'hello', $url = 'http://www.some-link.de', $width=640, $height=480, $top=0, $left=0 );
?>
o