Announcement

#1 2008-11-28 21:04:12

repie38
Former Piwigo Team
grenoble (FR)
2006-05-23
418

event handler and "$content"

wiki says :

An example of event is ‘render_user_comment_content’. PWG will give in input the raw content of a comment, you can modify it at your will (for example allow bbcode or add smilies) and return the value:

register_event_handler('render_user_comment_content', 'my_function');
function my_function($content)
{
  $content = str_replace(':)', '<img src="http://example.com/icon_smile.gif" alt=":)" />', $content);
  return $content; //<-- NOTE: this is how you return the value to PWG
}


i search'd in piwigo code, but i can't find where $content is assigned.
later, i found that by a plugin :
add_event_handler('render_element_content', array(&$obj, 'paMOOramics_load'),51,2);
and
add_event_handler('render_element_content', array(&$obj, 'paMOOramics_load'),50,2);

didn't get the same result for $content:

with priority 50 : $content is empty
with priority 51 : $content is  "<img src="./galleries/panorama3/autrans.jpg" style="width:3954px;height:600px;" alt="autrans.jpg">"


nb: tested on RC4 without modifications, and 1 active plugin (the one who get $content results)

Last edited by repié38 (2008-11-28 21:13:28)

Offline

 

#2 2008-11-28 21:22:32

P@t
Piwigo Team
Nice
2007-06-13
4098

Re: event handler and "$content"

It's normal... $content is assigned in picture.php, line 136:

add_event_handler(
  'render_element_content',
  'default_picture_content',
  EVENT_HANDLER_PRIORITY_NEUTRAL,
  2
);

If you want to assign your own content, you can use any event priority...
If you want to modify default content, you must use priority > 50

If it's not clear enough... I can explain better in french section ;-)

Last edited by P@t (2008-11-28 21:23:33)


P@t

Offline

 

#3 2008-11-28 21:34:42

repie38
Former Piwigo Team
grenoble (FR)
2006-05-23
418

Re: event handler and "$content"

thanks a lot!
that's clear enough ;)

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact