Component Development Doubt [solved]

This forum is for general questions about extensions for Joomla! 2.5.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
proveyourself
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Thu Oct 15, 2009 2:12 pm

Component Development Doubt [solved]

Post by proveyourself » Fri Feb 04, 2011 5:21 pm

Hi, I can add ckforms (Joomla 1.5) in an article using {ckforms} tag. I've tried to develop my own component. How do I do something similar to ckforms?
Thank you.
Last edited by proveyourself on Fri Feb 04, 2011 8:01 pm, edited 1 time in total.

 
proveyourself
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Thu Oct 15, 2009 2:12 pm

Re: Component Development Doubt

Post by proveyourself » Fri Feb 04, 2011 8:01 pm

Actually I've made a plugin:

/plugins/content/contactform/contactform.php

Code: Select all

<?php

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

jimport('joomla.plugin.plugin');

class plgContentContactForm extends JPlugin
{
	public function __construct(&$subject, $config)
	{
		parent::__construct($subject, $config);
	}

	public function onContentBeforeDisplay($context, &$row, &$params, $page=0)
	{
	    // Get template content
	    $template = file_get_contents(dirname(__FILE__) . DS . 'tmpl' . DS . 'default.php');
	    $row->text = str_replace('{contact-form}', $template, $row->text);
	}
}
plugins/content/contactform/tmpl/default.php

Code: Select all

<?php
// No direct access
defined('_JEXEC') or die;
?>
<form>
    <fieldset>
        <label for="name">Nome</label>
        <input id="name" name="name" />
        <label for="email">E-mail</label>
        <input id="email" name="email" />
        <label for="phone">Telefone</label>
        <input id="phone" name="phone" />
        <label for="subject">Assunto</label>
        <select id="subject" name="subject">
            <option value="">-- Selecione --</option>
            <option value="">Dúvidas</option>
            <option value="">Elogios</option>
            <option value="">Sugestões</option>
            <option value="">Reclamações</option>
            <option value="">Outros assuntos</option>
        </select>
        <label for="message">Mensagem</label>
        <textarea id="message" name="message"></textarea>
    </fieldset>
    <input type="submit" />
</form>
When {contact-form} is found in an article, it's replaced by the form.
Thank you.

 

Locked

Return to “Extensions for Joomla! 2.5”