Thursday, December 12, 2013

Joomla load module anywhere

if (!class_exists( 'CarsModelCars' )){
   JLoader::import( 'cars', JPATH_BASE . DS . 'components' . DS . 'com_cars' . DS . 'models' );
}

Now create an object for that class

Thursday, December 5, 2013

Use JQuery Squeeze box for modal display

To use modal pop up in joomla, there is an in-built javascript plugin Squeeze box based on the mootools library.

JHtml::_('behavior.modal');

This will add the squeeze box modal library.

And then add a class "modal" to the anchor.

Example
<a href="http://www.example.com/somepage.html" 
class="modal" rel="{size: {x: 700, y: 500}, handler:'iframe'}" 
id="modalLink1">
Click here to see this interesting page</a>

The above will load a iframe in modal box.

Reference
http://www.spiralscripts.co.uk/Joomla-Tips/using-modal-windows-with-joomla.html

Monday, December 2, 2013

Check if a var available in jQuery

This functions returns value 1 if var has some value and 0 when var is not present

jQuery.fn.exists = function(){return this.length>0;}

if ($(selector).exists()) {
    // Do something
}