Set plugin to afterDisplayContent event

4 years 10 months ago #42681 by dmayak
Hello, just want to ask for advice, I have the plugin that's working fine with Flexicontent (social share buttons plugin) but it is called on onContentAfterDisplay, so its contents outputs inside "text" field. I want to try to change it to output after all page content, since there are few other fields after text. I am using a copy of blog template and inside item template I can see
$this->item->event->afterDisplayContent;
, which I suppose is the event triggering, but changing
public function onContentAfterDisplay
to
public function afterDisplayContent
or to
public function onafterDisplayContent
seems do not trigger the plugin. Maybe I need to change the plugin group, its currently 'content'? I have looked into all FAQ entries related to plugins, but it focused on triggering plugins inside fields, not inside template.
I have also tried to trigger afterDisplayContent with JEventDispatcher, but got an error - cannot redeclare JDispatcher class. How to correctly set plugin to trigger on afterDisplayContent?

Please Log in or Create an account to join the conversation.

4 years 10 months ago #42696 by ggppdk
Hello

what about moving the whole output of the event inside you custom template?

1. duplicate a built-in template to create a custom template 'mydefault'

2 edit component/com_flexicontent/templates/mydefault/item.php
and copy inside item.php ... the contents of
component/com_flexicontent/tmpl_common/item_layouts/modular.php

3. continue editing item.php and move the following code:
<?php if ($item->event->afterDisplayContent) : ?>
	<!-- BOF afterDisplayContent -->
	<div class="fc_afterDisplayContent group">
		<?php echo $item->event->afterDisplayContent; ?>
	</div>
	<!-- EOF afterDisplayContent -->
<?php endif; ?>


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

4 years 10 months ago #42724 by dmayak
Thank you, this worked well with other plugins, but that one seemed to be of the kind that is added only to element text, regardless of where the event was called, although I have not found any conditions in its code. So I have abandoned it and trying to use a module instead.

Please Log in or Create an account to join the conversation.

4 years 10 months ago #42726 by ggppdk
Hello

- i see this a practice followed by some developers to avoid problems with template that do not print the
afterDisplayContent text



normally the afterDisplayContent() function
should do something like:
return $afterDisplayContent_text;

instead they do something like:
$item->text .= $afterDisplayContent_text;

best it would be if the developer had added a parameter for this

thanks for feedback

Regards


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

4 years 10 months ago #42830 by dmayak
Yes, you are right, now when I am understood what to look for, I have found this:
$row->text .= $html;
where $html is the main plugin output. Now I can output plugin where I need. Thank you.

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.