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
Hello
could we have the full code with the add_event_handler
eg [Github] Pure_autumn file themeconf.inc.php@L19
Offline
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
Got it working, I'm really not sure what was wrong except apparently needing to deactivate then reactivate the plug-in.
Offline