Twitter
Fri
30
May
'08
PDF
Print
Send
 
Hits (4191) | Comments (5) | Favorited (2) | Votes (0)

Introduction

This tutorial shows how to do things, which are all other plugin do for core Joomla content.

First it is important to understand difference between Core Joomla Content (CJC) and Mighty Content (MC). CJC has only one field and it's type html. So it is more easier to treat that. JSC has unpredictable number of fields and types. There may be custom field types developed especialy for some project. Thus there are 2 differenses.

1 difference - number of fields

Let me tel you example. You have comment plugin (though Mighty Content has comments built-in). This plugin attach or append to the end of article text link to comments and show how many comments are already there. This is ok if you have one field like CJC. But if you have many fields? Then we will get comments(0) link as many times as there are many fields. The conclusion is that there are 2 types of plugins. First is text parsers, plugins that replase {SOMETHING} to ANYTHING and Appending plugins that add to the end othe article additional inforation.

In CJC it may be done in one event but in MC ther are 2 different events for that.

One is onBeforeFieldRender - treat every field used basicaly for parser plugins. Thhis event is called before render or even prepare any field value. But do not forget skip usless types (read second difference).

Other onAfterArticleRender or onBeforeArticleRender.These events may be used for adding something before or after article. But realy you can reposition that in template.

2 difference - different types

This should be taken in account when you create parser like plugins. This means you need to skip types or treat only special type. like in example below that do something only with HTML texts. And this opens endless possibilities. imagine what you can do with picture type for example. Though it may be implemented in field plugin, you may place watermark on the fly or for email field send some alert to this email, and it is just what come to mind but relay it much bigger area.

Installation

You need to install plugins to joomsuite_content group. E.g. in installation XML

 
<install version="1.5" type="plugin" group="joomsuite_content" method="upgrade"> 
 

Plugin Example

 
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.plugin.plugin' );
 
class plgJoomsuite_contentExample extends JPlugin
{
    function plgJoomsuite_contentExample( &amp;$subject, $params )
    {
        parent::__construct( $subject, $params );
    }
 
    function onBeforeFieldRender(&amp;$field, &amp;$user)
    {
        $field_id         = $field->id;
        $field_value     = $field->field_value;
        $field_params     = new JParameter($field->params);
        $title             = $field->title;
        $type             = $field->type;
 
        if($type == 'html')
        {
            $field->field_value = str_replace("{PLACE_HOLDER}", 
              "Something Here", $field_value);
        }
    }
 
    function onAfterArticleRender(&amp;$article, $params)
    {
        $title = $article->title;
        $article_id = $article->id;
        $text = '';
        if($mode == 'list')
        {
            $text .= "This is article in list vew";
        }
        else 
        {
            $text .= "This is article details";
        }
        return $text;
    }
    function onBeforeArticleRender(&amp;$article, $params)
    {
        // same parameters here
    }
    function onArticleSubmit(&amp;$record, $params)
    {
    }
 
    function onCommentsRender(&amp;$record, &amp;$comments, &amp;$params)
    {
    }
 
    function onBeforeListRender(&amp;$params)
    {
    }
}
?>

Comments
CoocaAvatar
Quote
- -
Written by Cooca VIP on 30 June 2008

I am trying to use this example, but I just can not understand your english.

Do you have any more details on this, or a more indepth example?

If I can get to grips with what you are trying to explain, I will even rewrite the details for you in a more understandable format...

Steve

-
scholattuAvatar
Quote
- -
Written by scholattu VIP on 29 July 2008

Hi,

How to find a specific field so that I can give custom layout to that field?

For example, I have 5 fields in a content item. In the article view, I want to show 2 of those fields in a different layout. how do I do that?

thanks

 

-
serhioromanoAvatar
Quote
- -
Written by serhioromano VIP on 29 September 2008

@Sandeep
To controll field layout you need to read this article

 

-
gusvazAvatar
Quote
- -
Written by gusvaz on 05 January 2009

I don't understand anything

-
SerhioAvatar
Quote
- -
Written by Serhio STAFF on 06 January 2009

To understand this article you should be an advanced PHP/Joomla developer.

-
Add New Comment
Name:
Email:
Comment:
Attachment
Hide Comment
Security code:
Enter text as you see on image
 
 
What is best way for Download/Installation MightyExtensions?
 


Member Area



Member Activity

We have 2022 guests and 7 members online


MightyTemplate - Professional Joomla Templates