Call plugin inside collector view

Si vous avez des questions sur le fonctionnement du composant
oceanosoft
Messages : 2
Enregistré le : jeu. 23 juin 2011 16:15

Call plugin inside collector view

Message par oceanosoft »

Hello steevo!

First of all, thanks for your amazing component. I love it!
Hope you keep up the good work.
Now to my question:
I've created a custom field in the collector fields.
Its a multi line text field and inside this field I want collector to load a plugin, with the code {plugin}code{/plugin}
In this case I want to add a youtube video using {youtube}videoid{/youtube}
On a normal article, the plugin works well, but in the collector field, it only shows the code.
The video won't load.
On another component I neded to edit the code:
/public_html/components/com_djcatalog2/views/items/tmpl/default.php
Code to change is in line 58

Code : Tout sélectionner

<?php echo $this->category->description; ?>
replace it with this code

Code : Tout sélectionner

<?php
$description = JHTML::_('content.prepare', $this->category->description);
But the collector view page is a lot different and I don't know how to edit it to get the plugin working.
Can you help me?
Thanks!
echo $description;
?>

oceanosoft
Messages : 2
Enregistré le : jeu. 23 juin 2011 16:15

Re: Call plugin inside collector view

Message par oceanosoft »

Well, got it solved by myself.
I will post the solution here just in case anybody else is interested in calling plugins inside collector.
Just check that the plugin is enabled and working.
Then open /components/com_collector/views/item/tmpl/default_default.php

Replace on line 15:

Code : Tout sélectionner

<?php echo $this->createFieldDescription($field); ?>

With:

Code : Tout sélectionner

<?php echo $output = JHTML::_('content.prepare', $this->createFieldDescription($field)); ?>
Save the file and you are done!
Now plugins called in a custom field get displayed.

Avatar du membre
steevo
Administrateur du site
Messages : 330
Enregistré le : jeu. 17 déc. 2009 22:59
Contact :

Re: Call plugin inside collector view

Message par steevo »

Hi!
Thank you for that. I thought that i had made it work but i think that it's only on my dev version.
I will implement that in next version.
Thank you again.

Avatar du membre
steevo
Administrateur du site
Messages : 330
Enregistré le : jeu. 17 déc. 2009 22:59
Contact :

Re: Call plugin inside collector view

Message par steevo »

I found what i did on my dev version:
in the file components\com_collector\views\item\view.html.php

replace

Code : Tout sélectionner

		/*
		 * Process the prepare content plugins
		 */
		JPluginHelper::importPlugin('collector');
by

Code : Tout sélectionner

		/*
		 * Process the prepare content plugins
		 */
		JPluginHelper::importPlugin('content');
		
		$dispatcher =& JDispatcher::getInstance();
        $article->params = clone($params);
		
		foreach ( $fields as $field )
		{
			if ($field->type == 2)
			{
				$field_name = 'field_'.$field->id;
				$article->text = & $item->$field_name;
				$dispatcher->trigger('onPrepareContent', array (& $article, & $article->params, 0));
			}
		}

Répondre