Announcement

  •  » Engine
  •  » Unable to get a prefilter to work

#1 2016-12-21 10:26:53

Cynbel
Member
2016-07-27
8

Unable to get a prefilter to work

Hi,

so I'm needing to modify the user collections plugin, essentially adding additional information. I would like to make a form around the thumbnails to add a quantity field for each thumbnail in the collection, I figured the best way to do this would be using a prefilter doing a search and replace unfortunately I can't seem to get it to work even to do something simple.

My assumption would be to do this either before or after these in collections.inc.php

$template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button');
$template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox');

since both deal with changing thumbnails.tpl.

I could be completely going at this the wrong way

Any help would be great,
Thank you

Offline

 

#2 2016-12-21 10:51:28

flop25
Piwigo Team
2006-07-06
7037

Re: Unable to get a prefilter to work

Hello
could we have the full code with the add_event_handler
eg [Github] Pure_autumn file themeconf.inc.php@L19


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#3 2016-12-22 01:03:04

Cynbel
Member
2016-07-27
8

Re: Unable to get a prefilter to work

add_event_handler('loc_end_index_thumbnails', 'user_collections_form');

function user_collections_form($tpl_thumbnails_var)
{
    global $template;
    $template->set_prefilter('index_thumbnails', 'user_collections_form_prefilter');
    return $tpl_thumbnails_var;
}

function user_collections_form_prefilter($content, &$smarty)
{
    $replace = file_get_contents(USER_COLLEC_PATH.'template/uc_form_add.tpl');
    $search = '/({foreach from=\$thumbnails item=thumbnail}).*({\/foreach})/is';
    return preg_replace($search, $replace, $content);
}


The add_event_handler is before the two set_prefilter already mentioned. I would like to get it to replace the whole foreach section of the thumbnails.tpl Figured that would be the easiest way to set it up as a form instead of doing multiple search replace. The search regex appears to work on the tumbnails.tpl itself, but it could be an issue of when it occurs?

Offline

 

#4 2016-12-22 02:09:11

Cynbel
Member
2016-07-27
8

Re: Unable to get a prefilter to work

Got it working, I'm really not sure what was wrong except apparently needing to deactivate then reactivate the plug-in.

Offline

 
  •  » Engine
  •  » Unable to get a prefilter to work

Board footer

Powered by FluxBB

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