Welcome, Guest
Username: Password: Remember me

TOPIC: [HOWTO] Content plugin to work with Cook

[HOWTO] Content plugin to work with Cook 31 May 2013 09:27 #7263

  • molenwal1
  • molenwal1's Avatar
  • Offline
  • Senior Member
  • Posts: 63
  • Thank you received: 17
  • Karma: 3
I installed a content plugin easiertube, this plugin translates youtube urls to emmbed video of such a video.

It is working in a common Joomla article, but not in a rich text field in a Joomla component. The field is used in a fly brick.

I think i have done this before, somewhere i can define the plugins that i want to use in my J-cook component, but i cannot find it. Who can help me with this?
Molenwal1 Webdesign
www.molenwal1.nl
The administrator has disabled public write access.

[HOWTO] Content plugin to work with Cook 03 Jun 2013 14:56 #7299

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
You may have to fire the trigger for that.
Get a look how com_content is triggering the pluggins

onContentPrepare() I think...

When you have done this please share it here because it can be included in Cook easily I think.
Coding is now a piece of cake
The administrator has disabled public write access.

[HOWTO] Content plugin to work with Cook 03 Jun 2013 17:45 #7306

  • molenwal1
  • molenwal1's Avatar
  • Offline
  • Senior Member
  • Posts: 63
  • Thank you received: 17
  • Karma: 3
I was trying with the onContentPrepare option. Did the following in view.html.php:
$dispatcher	= JDispatcher::getInstance();
		//
		// Process the content plugins.
		//
		JPluginHelper::importPlugin('content');
		$results = $dispatcher->trigger('onContentPrepare', array ('com_mw1crowdfunding.projectitem', &$item, &$this->params, 0));

Unfortunately this is resulting in:
Notice: Undefined property: stdClass::$text in /public_html/plugins/content/easyembed/easyembed.php on line 12

The same error on more lines and more plugins.

Reason is that plugin is using a field text which i do not have in my table.
if (strpos($article->text, '{noembedvideo}') !== FALSE)

Will look for workaround.
Molenwal1 Webdesign
www.molenwal1.nl
The administrator has disabled public write access.

[HOWTO] Content plugin to work with Cook 04 Jun 2013 05:29 #7310

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Thanks for investigating.

This means only the text field can be used.

Do you want to force it and with a little trick being able to do it ?
//Keep 'text' property value if exists
if (isset($item->text))
  $tmp_text = $item->text;

//Set the text property for the pluggin
$item->text = $item->myTextVar;

//TRIGGER HERE

//Apply the changes
$item->myTextVar = $item->text;

//Restore original value of 'text'
if (isset($tmp_text))
  $item->text = $tmp_text;
Hope it helps
Coding is now a piece of cake
Last Edit: 04 Jun 2013 05:32 by admin.
The administrator has disabled public write access.

[HOWTO] Content plugin to work with Cook 04 Jun 2013 09:08 #7316

  • molenwal1
  • molenwal1's Avatar
  • Offline
  • Senior Member
  • Posts: 63
  • Thank you received: 17
  • Karma: 3
Thank you, i have two text fields in the view, next piece of script works:
$dispatcher	= JDispatcher::getInstance();

                //Plugins projectitem
                //Keep 'text' property value if exists
                if (isset($item->text))
                   $tmp_text = $item->text;

                //Set the text property for the plugin field description
                $item->text = $item->description;

		//
		// Process the content plugins.
		//
		JPluginHelper::importPlugin('content');
		$results = $dispatcher->trigger('onContentPrepare', array ('com_mw1crowdfunding.projectitem', &$item, &$this->params, 0));

                //Apply the changes
                $item->description = $item->text;

                //Set the text property for the plugin field projectowner_id_about
                $item->text = $item->_projectowner_id_about;

		//
		// Process the content plugins.
		//
		$results = $dispatcher->trigger('onContentPrepare', array ('com_mw1crowdfunding.projectitem', &$item, &$this->params, 0));

                //Apply the changes
                $item->_projectowner_id_about = $item->text;

                //Restore original value of 'text'
                if (isset($tmp_text))
                   $item->text = $tmp_text;
Molenwal1 Webdesign
www.molenwal1.nl
Last Edit: 04 Jun 2013 09:09 by molenwal1.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

[HOWTO] Content plugin to work with Cook 05 Jun 2013 16:59 #7362

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Thank you very much.
Not tested in my own, but I can see you investigate and share.
When I will implement this I will study and reuse your source.

Bookmarked

Moved in 'Coding...'

K+1
Coding is now a piece of cake
The administrator has disabled public write access.

Re: [HOWTO] Content plugin to work with Cook 06 Jun 2013 04:32 #7375

  • molenwal1
  • molenwal1's Avatar
  • Offline
  • Senior Member
  • Posts: 63
  • Thank you received: 17
  • Karma: 3
Ok, thank you. To be complete in my information, i only used the OnContentPrepare trigger.

In content article there are also triggers for OnConentAfterTitle, OnContentBeforeDisplay and OnContentAfterDisplay.

view.html.php
//
		// Process the content plugins.
		//
		JPluginHelper::importPlugin('content');
		$results = $dispatcher->trigger('onContentPrepare', array ('com_content.article', &$item, &$this->params, $offset));

		$item->event = new stdClass();
		$results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$this->params, $offset));
		$item->event->afterDisplayTitle = trim(implode("\n", $results));

		$results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$this->params, $offset));
		$item->event->beforeDisplayContent = trim(implode("\n", $results));

		$results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$this->params, $offset));
		$item->event->afterDisplayContent = trim(implode("\n", $results));

tmpl/default.php after title and before text:
<?php  if (!$params->get('show_intro')) :
	echo $this->item->event->afterDisplayTitle;
endif; ?>

<?php echo $this->item->event->beforeDisplayContent; ?>

tmpl/default.php at the end:
<?php echo $this->item->event->afterDisplayContent; ?>
Molenwal1 Webdesign
www.molenwal1.nl
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Re: [HOWTO] Content plugin to work with Cook 12 Feb 2014 10:34 #12182

  • mtifinn
  • mtifinn's Avatar
  • Offline
  • Junior Member
  • Posts: 20
  • Thank you received: 2
  • Karma: 0
I also want to get content plugins to work in my component.

I am trying to follow your lead, but I am unsure of which files to edit.
view.html.php would seem to be the one in views/MYVIEW

But where is tmp/default.php ?

Sorry if this is a dumb question
The administrator has disabled public write access.
Time to create page: 0.118 seconds

Get Started