Alejo Sotelo - Extensions

Tools
A+ R A- wide normal
Login
  • Skip to content
You are here » Home » Hacer plugins para joomla 1.6
Español (spanish formal Internacional)English (United Kingdom)
  • InicioHome
  • ExtensionesExtensions
    • AS Estate Agent Show 
    • AS Estate Agent Categories 
    • AS Google AnalyticsAS Google Analytics
    • JLoremPlugin
  • Blog 
  • ContactarContact us
Rate this item
  • 1
  • 2
  • 3
  • 4
  • 5
(0 votes)

Crear Plugins para Joomla 1.6! Featured

  • Written by  Alejo Sotelo
  • font size decrease font size decrease font size increase font size increase font size
  • Print
  • E-mail
  • Be the first to comment!

En este tutorial explicare como desarrollar un plugin para Joomla 1.6, basandome en algunos tutoriales en ingles y en mi experiencia personal de desarrollo.

Que es un plugin?

Un plugin es una app dentro de Joomla que sirve para modificar los comportamientos naturales del CMS, interceptando los eventos predefinidos en Joomla y ejecutando asi nuestro app antes o despues de dicho evento.

Con los plugins se puede desde escribir un simple holamundo hasta una compleja galeria de imagenes.

Estos se dividen en diferentes tipos:

  • authentication (se usa en la autentificacion de usuarios.)
  • content (se ejecuta en el contenido. Usaremos este en el ejemplo.)
  • editors (son los editores, tinymce, jck, ect.)
  • editors-xtd (son los botones debajo de los editores: imagen, leer mas, etc.)
  • extension (todavia no lo se pero supongo que es para cuando se instala alguna extension o cuando se actualiza.)
  • search (no lo se, se debe ejecutar cuando se realiza algun tipo de busqueda.)
  • system (se ejecuta en eventos del sistema.)
  • user ( se ejecuta cuando se loguea, elimina, etc. un usuario.)
Empezaremos por la estructura:
  • name (nombre extension en minuscula y sin espacios)
    • language
      • es-ES
        • es-ES.plg_content_name.ini
        • es-ES.plg_content_name.sys.ini
        • index.html
      • en-GB
        • en-GB.plg_content_name.ini
        • en-GB.plg_content_name.sys.ini
        • index.html
      • index.html
    • name.php
    • name.xml
    • index.html
La estructura de nuestro ejemplo quedaria de la siguiente manera:
  • holamundo (nombre extension en minuscula y sin espacios)
    • language
      • es-ES
        • es-ES.plg_content_holamundo.ini
        • es-ES.plg_content_holamundo.sys.ini
        • index.html
      • en-GB
        • en-GB.plg_content_holamundo.ini
        • en-GB.plg_content_holamundo.sys.ini
        • index.html
      • index.html
    • holamundo.php
    • holamundo.xml
    • index.html

Como vemos se utiliza la misma estructura que para Joomla 1.5 solo que se agrego la carpeta language, que es donde se guardan los diferentes lenguajes (antes se debia crear los archivos en la carpeta "joomla_root/language/").

Vamos al fichero de instalacion y parametros.

holamundo.xml

<?xml version="1.0" encoding="utf-8"?>
<extension version="1.6" type="plugin" group="content">
<name>plg_content_holamundo</name>
<author>AlejoSotelo.com.ar</author>
<creationDate>July 2010</creationDate>
<copyright>Copyright (C) 2009 - 2011 AlejoSotelo.com.ar, All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail> This e-mail address is being protected from spambots. You need JavaScript enabled to view it </authorEmail>
<authorUrl>www.alejosotelo.com.ar</authorUrl>
<version>1.0</version>
<description>PLG_CONTENT_HOLAMUNDO_XML_DESCRIPTION</description>
<files>
<filename plugin="holamundo">holamundo.php</filename>
<filename>index.html</filename>
<folder>language</folder>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_content_holamundo.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_content_holamundo.sys.ini</language>
<language tag="es-ES">es-ES/es-ES.plg_content_holamundo.ini</language>
<language tag="es-ES">es-ES/es-ES.plg_content_holamundo.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="texto" type="text" description="TEXTO_DESC" label="TEXTO"    />
</fieldset>
</fields>
</config>
</extension>

Como vemos el xml de instalacion cambio algunas estructuras pero se mantiene un linea con respecto a joomla 1.5

Vamos al archivo de la aplicacion en si.

 

holamundo.php

/**
* @version $Id: holamundo.php 20196 2011-01-09 02:40:25Z ian $
* @package AlejoSotelo.com.ar
* @subpackage Content
* @copyright Copyright (C) 2009 - 2011 AlejoSotelo.com.ar, All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access
defined('_JEXEC') or die;

jimport('joomla.plugin.plugin');

/**&
* Ejemplo Content - HolaMundo Plugin
*
* @package AlejoSotelo.com.ar
* @subpackage Content
* @since 1.6
*/
class plgContentHolaMundo extends JPlugin
{

/**
* Constructor del plugin.
**/
function plgContentHolaMundo(&$subject, $params) {
parent::__construct($subject, $params);
}

/**
* El metodo es llamado antes de mostrar el contenido en los articulos.
* Debajo del titulo.
**/
public function onContentBeforeDisplay($context, &$article, &$params, $limitstart){

// Obtengo el parametro 'texto' del plugin con el valor por default 'alejo sotelo extensions'.
// get(nombreParametro, valorPorDefault)
$texto = $this-&>params-&>get('texto','alejo sotelo extensions');

// Armo el texto a mostrar.
$html = 'Plugin HolaMundo dice: ' . $texto;

// Retorno el valor a mostrar despues del titulo.
return $html;
}

}

Read 212 times
Published in Joomla
Tagged under
  • joomla 1.6
  • plugins
Social sharing
  • Add to Google Buzz
  • Add to Facebook
  • Add to Delicious
  • Digg this
  • Add to Reddit
  • Add to StumbleUpon
  • Add to MySpace
  • Add to Technorati
Alejo Sotelo

Alejo Sotelo

Website: www.alejosotelo.com.ar

Latest from Alejo Sotelo

  • Transperez
  • High Royal
  • Marshall Center Brieft
  • The Watch
  • Etnies Footwear

Leave a comment

back to top
Joomla extensions developer © AlejoSotelo.com.ar. All rights reserved.



  • Forgot your password?
  • Forgot your username?
  • Create an account