Thứ Sáu, 31 tháng 5, 2013

Framework Leo Restro

Leo Restro

Leo Restro comes in 3 theme colors to suit your style and support customization for background and fonts via template configuration. Leo Restro is built on the Leo Framework.
Leo Restro

Responsive Joomla template Puresite

Puresite

Puresite is a simple and clean yet beautifully presented responsive Joomla template. This template works well and fits any screen sizes, and the minimalistic design makes it look great.
Puresite

Responsive template Joomla Dagen

JoomlaDagen

JoomlaDagen is a responsive template for Joomla 1.7. The template is also using Twitter Bootstrap, Skeleton and Google Fonts.
JoomlaDagen

CMS Blue

CMS Blue

CMS Blue is a simple responsive theme that offers the basics but you can always use your creativity to modify. This CMS Theme also comes in different colors and style; CMS Grey, CMS Water and CMS White.
CMS Blue

Responsive joomla template Elastica

Elastica

Elastica is both beautiful and well presented responsive, and it can fit to all screen sizes, including extra widescreen. Elastica is built on JAT3 2 Framework and jQuery Masonry script.
Elastica

Joomla 2.5 template Cameleon

Cameleon

Cameleon is a Joomla 2.5 template built with a responsive design to fit into any screen size available out there. The template comes with rtl support, JJ Slider and accordion menu, Google Fonts and more. It’s also compatible with Joomla 1.6.x – 1.7.x and Joomla 2.5.x

Responsive Joomla template Music

Music

Music is a free responsive Joomla template from GavickPro. This Joomla template produces a breathtaking Web site that will catch your visitors’ attention.
Music

Thứ Năm, 23 tháng 5, 2013

Convert a MySQL database to UTF-8

After searching a long time for a solution when I upgraded from MySQL 4.0 to 5.0 I found this,
mysqldump --user=username --password=password --default-character-set=latin1 --skip-set-charset dbname > dump.sql
sed -r 's/latin1/utf8/g' dump.sql > dump_utf.sql
mysql --user=username --password=password --execute="DROP DATABASE dbname; CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;"
mysql --user=username --password=password --default-character-set=utf8 dbname < dump_utf.sql
This worked perfectly for me.

Changing multi-column article order in section and category blogs

Problem

Note: The ability to order articles across columns was added as a new feature in version 1.5.7. So this Tip only applies versions 1.5.6 and earlier. Upgrading to 1.5.7 is strongly recommended for security reasons as well.
Section and Category Blog pages with 2 columns put articles in order down the column, as shown below:
article 11 (continued)
article 2article 4
article 3article 5
The Front Page Blog puts articles in order across columns, as shown below:
article 11 (continued)
article 2article 3
article 4article 5
Some Joomla! users prefer the way the Front Page works over the way the other blogs work and want to change the Section and Category Blogs to order articles like the Front Page.

Headline text

Solution

Using the Template Override feature of Joomla! 1.5, we can replace the code for the Section and Category blog ordering with the code from the Front page. Here are the steps:
  1. Create the override directory for the Category Blog as follows: "<your joomla! home>/templates/<your template>/html/com_content/category".
  2. Copy the attached file "blog.txt" to the new directory. Rename it to "blog.php". This file is modified to order articles like the Front Page blog.
  3. Simlarly, for the Section Blog, create a directory called <your joomla home>/templates/<your template>/html/com_content/section".
  4. Copy the attached file "blog.txt" into this directory and rename it "blog.php". This file is modified to order articles like the Front Page blog.
With these files installed and renamed, the Category and Section blogs should order articles across columns, just like the Front Page. If for any reason these files cause problems in your site, you can just delete them and the default files will be used instead. See the links above for details on the edits made for these files.
Note that this solution is for Joomla! version 1.5.x and may not work for 1.6 and later versions.

Auto redirect guests to login

Desired Functionality

Suppose you have some menu choices that require a user to be logged in, like "Submit an Article". You would like all users to be able to see the restricted menu item, whether or not they are logged in.
If the user is logged in, they just go directly to the restricted menu item.
If the user is not logged in
  • they are presented with the login form, and
  • once they log in successfully, they continue on to the restricted page.
If they are not registered, they have the option to register or navigate to another page.

Solution

Here is how you do this in Joomla!.
  1. Create a new menu from menu manager, say it is named "hidden menu".
  2. Add any menu items that will be accessible only to registered users (for example, "Submit an Article"). Set the required access levels of these menu items ("Special" in this example, but it could also be "Registered").
  3. Do NOT create a module for the "hidden menu". It will not be displayed on any page, so it doesn't need a module.
  4. Create your "real" menu (for example, "main menu") and the menu item that will display for all users (for example "Submit an Article").
    • The menu item will have a menu item type of "Alias".
    • It's "Menu Item" parameter will be the "Submit an Article" menu item on the "hidden menu".
    • The Access Level for this menu item will be "Public", since we want everyone to be able to see and use it.
  5. Create a module of type "mod_mainmenu" for this menu, just like you do for any menu.
  6. If you want sub-menus, make sure you've added the sub-menu items in the "main menu" and not the "hidden menu".
Now, when a guest (non-logged-in user) accesses the "Submit an Article" menu choice, it redirects them to the login page. If they log in successfully, they are taken to the desired page (in this case, "Submit an Article"). If there were already logged in, they go there directly.

Example

In my case, I've added the following menu items:
  1. HOME
  2. BLOG (IDOBlog)
  3. WIKI (A Wiki)
  4. DIRECTORY (SOBI2)
  5. CLASSIFIEDS (ads)
  6. FAQS (Articles section)
  7. SHOP (VirtueMart)
  8. Contact US (contacts)
I wanted that ALL the menu items are viewable by public (non-registered users included) at the front end. But I want that menu items 3,4,5,6 & 7 are accesible by REGISTERED users only. In other words if anyone clicks on menu item 3/4/5/6/7 they'll be lead to the login modules.
So, I created a "hidden menu" with the menu items for 3 - 7, using the restricted access level. Then, when I created the "real" menu, I used the menu type "Alias" for these items and set the "Menu Item" Parameter to the corresponding menu item in the "hidden menu".
As far as I know, this method is applicable to all menus in the menu manager. In case of any help or suggestion please contact me on forums.joomla.org my username is ziggy03. In case of a better or alternate method please feel free to edit this page. Thanks.

Adding access keys

Here's a quick way to add access keys to Joomla! 1.5.
Firstly edit the component.xml parameter definiton file in \administrator\components\com_menus\models\metadata and add to it an accesskey parameter:
<param name="accesskey" type="text" size="1" default="" label="Accessibility Access Key"
description="Accessibility Access Key for the page which this Menu item points to" />
Your file should now look something like:
    <?xml version="1.0" encoding="utf-8"?>
<metadata>
<state>
<name>Component</name>
<description>Component Parameters</description>
<params>
<param name="page_title" type="text" size="30" default="" label="Page Title"
description="PARAMPAGETITLE" />
<param name="show_page_title" type="radio" default="1" label="Show Page Title"
description="SHOW/HIDE THE PAGES TITLE">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="pageclass_sfx" type="text" size="20" default="" label="Page Class Suffix"
description="PARAMPAGECLASSSFX" />
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="menu_image" type="imagelist" directory="/images/stories" hide_default="1"
default="" label="Menu Image" description="PARAMMENUIMAGE" />
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="secure" type="radio" default="0" label="SSL Enabled" description="PARAMSECURE">
<option value="-1">Off</option>
<option value="0">Ignore</option>
<option value="1">On</option>
</param>
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="accesskey" type="text" size="1" default="" label="Accessibility Access Key"
description="Accessibility Access Key for the page which this Menu item points to" />
</params>
<advanced />
</state>
</metadata>
Now edit the frontend file \modules\mod_mainmenu\helper.php:
    // ACCESS KEY HACK - Part 1
$accessKey = $iParams->get('accesskey');
$tmp->accessKey = $accessKey;
and
    // ACCESS KEY HACK - Part 2
if ($tmp->accessKey)
$data = '<a href="'.$tmp->url.'" accesskey="'.$tmp->accessKey.'">'.$image.$tmp->name.'</a>';
else
$data = '<a href="'.$tmp->url.'" >'.$image.$tmp->name.'</a>';
into the _getItemData($item) function so that it looks like this
    function _getItemData($item)
{
$data = null;
 
// Menu Link is a special type that is a link to another item
if ($item->type == 'menulink')
{
$menu = &JSite::getMenu();
if ($tmp = clone($menu->getItem($item->query['Itemid']))) {
$tmp->name = '<span><![CDATA['.$item->name.']]></span>';
$tmp->mid = $item->id;
$tmp->parent = $item->parent;
} else {
return false;
}
} else {
$tmp = clone($item);
$tmp->name = '<span><![CDATA['.$item->name.']]></span>';
}
 
$iParams = new JParameter($tmp->params);
if ($iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
$image = '<img src="'.JURI::base(true).'/images/stories/'.$iParams->get('menu_image').'" alt="" />';
} else {
$image = null;
}
 
 
// ACCESS KEY HACK - Part 1
$accessKey = $iParams->get('accesskey');
$tmp->accessKey = $accessKey;
 
switch ($tmp->type)
{
case 'separator' :
return '<span class="separator">'.$image.$tmp->name.'</span>';
break;
 
case 'url' :
if ((strpos($tmp->link, 'index.php?') !== false) && (strpos($tmp->link, 'Itemid=') === false)) {
$tmp->url = $tmp->link.'&amp;Itemid='.$tmp->id;
} else {
$tmp->url = $tmp->link;
}
break;
 
default :
$router = JSite::getRouter();
$tmp->url = $router->getMode() == JROUTER_MODE_SEF ?
'index.php?Itemid='.$tmp->id : $tmp->link.'&Itemid='.$tmp->id;
break;
}
 
// Print a link if it exists
if ($tmp->url != null)
{
// Handle SSL links
$iSecure = $iParams->def('secure', 0);
if ($tmp->home == 1) {
$tmp->url = JURI::base();
} elseif (strcasecmp(substr($tmp->url, 0, 4), 'http') && (strpos($tmp->link, 'index.php?') !== false)) {
$tmp->url = JRoute::_($tmp->url, true, $iSecure);
} else {
$tmp->url = str_replace('&', '&amp;', $tmp->url);
}
 
switch ($tmp->browserNav)
{
default:
case 0:
// _top
// ACCESS KEY HACK - Part 2 ###############################
if ($tmp->accessKey)
$data = '<a href="'.$tmp->url.'" accesskey="'.$tmp->accessKey.'">'.$image.$tmp->name.'</a>';
else
$data = '<a href="'.$tmp->url.'" >'.$image.$tmp->name.'</a>';
break;
case 1:
// _blank
$data = '<a href="'.$tmp->url.'" target="_blank">'.$image.$tmp->name.'</a>';
break;
case 2:
// window.open
$attribs = 'toolbar=no,location=no,status=no,menubar=no,
scrollbars=yes,resizable=yes,'
.$this->_params->get('window_open');
 
// hrm...this is a bit dickey
$link = str_replace('index.php', 'index2.php', $tmp->url);
$data = '<a href="'.$link.'" onclick="window.open(this.href,\'targetWindow\',\''.$attribs.'\');
return false;">'
.$image.$tmp->name.'</a>';
break;
}
} else {
$data = '<a>'.$image.$tmp->name.'</a>';
}
 
return $data;
 
}
Login to your admin site and edit a menu item. Now open the "Parameters - System" accordion item on the right and you will see your accesskey parameter. Set a value, save the menu item and voila.

Thứ Tư, 22 tháng 5, 2013

Plugin Developer Overview


Joomla! 1.5 introduced the JPlugin class. In the effort to move Joomla! toward a more efficient object-oriented framework, a new plugin system has been developed which follows the Observer pattern. Plugins are observer classes that attach to a global event dispatcher object in the Joomla! core. What does this mean in English? It means that either the Joomla! core or a third party component or module can trigger an event which causes one or more plugins to execute some code.

Implementation

The implementation of the plugin system is that of an observer pattern. It has two parts, an observer class, JPlugin, and an observable class, JEventDispatcher.
/**
* JPlugin Class
*
* @package Joomla.Framework
* @subpackage Application
* @since 1.5
*/

class JPlugin extends JObserver
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @since 1.5
*/

function JPlugin(& $subject)
{
parent::__construct($subject);
}
 
/**
* Method to map events to handler methods
*
* @access public
* @param array Arguments
* @return mixed Routine return value
* @since 1.1
*/

function update( &$args )
{
/*
* First lets get the event from the argument array. Next we will unset the
* event argument as it has no bearing on the method to handle the event.
*/

$event = $args['event'];
unset($args['event']);
 
/*
* If the method to handle an event exists, call it and return its return
* value. If it does not exist, return a boolean true.
*/

if (method_exists($this, $event)) {
return call_user_func_array(array($this, $event), $args);
} else {
return true;
}
}
}
There are two important things that makes this class work.
One is the constructor which actually gets executed by the parent class of this class JObserver. The following is what happens in the constructor:
// Register the observer ($this) so we can be notified
$subject->attach($this);
 
// Set the subject to observe
$this->_subject = &$subject;
This attaches the JPlugin to an observable object. In the case of plugins, they observe the JEventDispatcher object.
The second important thing to note is the update method. The update method is passed an array from its trigger. The array contains two elements - the event and the arguments. Once the update method receives this array it extracts the event and removes it from the arguments. It then calls a method of name ‘event’ (passing the arguments array) and returns its response.

Third Party Usage

<?php
/**
* @version $Id: $
* @package
* @subpackage
* @copyright
* @license
*/

 
jimport('joomla.plugin');
 
 
/**
* Example Plugin
*
* @author
* @package
* @subpackage
* @since
*/

class ExamplePlugin extends JPlugin
{
/**
* Constructor
*
* @param object $subject The object to observe
* @since 1.1
*/

function ExamplePlugin( &$subject ) {
parent::__construct( $subject );
}
 
/**
* This method handles the onIncrement event. It takes an integer input and
* increments its value.
*
* @access public
* @param int $input An integer to increment
* @return int Incremented integer
* @since 1.1
*/

function onIncrement($input)
{
return $input++;
}
}
?>
As you can see, it is quite simple to create a JPlugin. It is truly as simple as creating a class that extends JPlugin and writing a method for each event you want the plugin to handle.