web design, England, Britain, UK, belgium
 
Ulti Clocks content

Joomla Cheat Sheet - Joomla & VirtueMart Tips & How To's

GJC Website Design UK, Joomla Developer, VirtueMart Developer, Template Developer, web site designs, England, Britain, UK, Belgium, search-engine optimisation (SEO). Multilingual.

Home Joomla - VirtueMart Virtuemart 2 AusPost Shipping Estimator Mod

Mon

28

Apr

  • Joomla
  • Cheat Sheet

Here's a list of Joomla code snippets so that I don't have to search the forums every time I need one!

Joomla 2.5

Find current page title

$mydoc =& JFactory::getDocument();
$title = $mydoc->getTitle();
.......................................................

Find current menu text

$active = JFactory::getApplication()->getMenu()->getActive();
$title = $active->title;
.......................................................

Find current menu link from Itemid

$menuitem is the Itemid

$item = JFactory::getApplication()->getMenu()->getItem( $menuitem );
$url = JRoute::_($item->link . '&Itemid=' . $item->id);
.......................................................

Get a var

$success = JRequest::getVar('success');
.......................................................

Just show the component

&tmpl=component
.......................................................

Show messages in component

$document = & JFactory::getDocument();
$renderer = $document->loadRenderer('message');
$msg=@$renderer->render();
.......................................................

Get the messages

$messages = JFactory::getApplication()->getMessageQueue();
//this is an array of queued messages - no html
.......................................................

Clear joomla messages

$app = JFactory::getApplication();
$app->set( '_messageQueue', '' ); //clear messages
.......................................................

Joomla session
set

$session = JFactory::getSession();
$previousValue = $session->set('myValue', $value,'myNameSpace');

get

$session = JFactory::getSession();
$value = $session->get('myValue', myDefault,'myNameSpace');
.......................................................

Add module to component
You can also pass prameters - form {"btuser":"83"}

$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('modules');
$position = 'comuser';
$options = array('style' => 'raw','params' => '{"btuser":"'.$userid.'"}' );
echo $renderer->render($position, $options, null);
.......................................................

Add js & css

$document = JFactory::getDocument();
$document->addScript(Juri::base() .'components/com_musicbattle/assets/js/imageflow.js');
$document->addStyleSheet(Juri::base() .'components/com_musicbattle/assets/css/imageflow.css');
.......................................................

Add a lang file

$lang = JFactory::getLanguage();
$extension = 'com_helloworld';
$base_dir = JPATH_SITE;
$language_tag = 'en-GB';
$reload = true;
$lang->load($extension, $base_dir, $language_tag, $reload);
.......................................................
 
Last Updated on Monday, 28 April 2014 14:31
 
VirtueMart
Your Cart is currently empty.



Joomla Cheat Sheet|Joomla & VirtueMart Tips & How To's



GJC Website Design UK, Joomla Developer, VirtueMart Developer, Template Developer, web site designs, England, Britain, UK, Belgium, search-engine optimisation (SEO). Multilingual.


jfactory, document, messages, joomla, session, title, getapplication, renderer, getdocument, base, component, add, item, itemid, css, current, lang, clear, value, myvalue, getsession, set, array, render, loadrenderer, options, dir, extension, language, tag, reload, imageflow, assets, position, btuser, juri, components, musicbattle, mynamespace, app

|

We use cookies to improve our website and your experience when using it. Cookies used for the essential operation of the site have already been set.
To find out more about the cookies we use and how to delete them, see our privacy policy.

I accept cookies from this site.