Announcement

  •  » Extensions
  •  » Change Contact Form plugin to popup form over top of picture page

#1 2017-08-11 02:21:43

cgcarter
Member
2017-08-09
14

Change Contact Form plugin to popup form over top of picture page

Hi Everyone

I'm trying to add functionality to Piwigo by modifying an existing plugin but I'm having some difficulty and am hoping for some help.

The feature to add: I need a feature that is a button, just below the image caption that, when clicked, presents a popup form that the user can use to email a link to the current picture to a friend.  It'd be like 'share via email'.

The how: Because such a plugin seems non-existent (correct me if I'm wrong), I chose to try and modify the ContactForm plugin.  It contains the necessary code, more or less, and the progress is kind of working.  Using CSS and changing the html tag id's I've gotten some degree of popup functionality.  I'm sure I can get there rest in time.

Here is where I am stuck: The button.  The ContactForm has its own page.  I need to take that HTML (or smarty template) and inject that just below the current picture being displayed in the template called 'picture.tpl' ('m using the theme bootstrap_darkroom) so that the html and php are rendered and I can hide/show that with my CSS.  I know php can do this injection, but I'm having difficulty getting it to work.  This confusion is confounded by the template system and the events/action system of Piwigo. 

In the ContactForm plugin, I have tried to change the event that seems to call the page to be rendered to instead render on 'render_element_description', like so:

add_event_handler('render_element_description', 'my_function');
function my_function($template)
{
//add it here
  return $template; //<-- NOTE: this is how you return the value to Piwigo
}

the idea being that within this php function, I would tell the $template to {include} the ContactForm template.  The thing is, I feel like I'm in the ballpark, but way off-base.

I hope all that makes sense and I'm looking forward to your help.  Apologies too for lengthiness.  This is actually the very first time in my life I've posted any forum topic.  (Yes, really). 

Thanks, All.

Piwigo version: 2.9.1
PHP version: 5.6.30
MySQL version: 5.5.51-38.2

Last edited by cgcarter (2017-08-11 02:29:55)

Offline

 

#2 2017-08-11 20:18:58

cgcarter
Member
2017-08-09
14

Re: Change Contact Form plugin to popup form over top of picture page

No thoughts on this? 

Long story short:  I need to inject the template from a plugin into the template for the theme.  I need to do this from within the plugin.  That's it.  Does anyone know how to do this?

Thanks.

Last edited by cgcarter (2017-08-11 20:19:50)

Offline

 

#3 2017-08-12 06:12:28

ddtddt
Piwigo Team
Quetigny - France
2007-07-27
7207

Re: Change Contact Form plugin to popup form over top of picture page

Hi :-)

for add element in template you must a pre filter

exemple for page picture

add_event_handler('loc_begin_picture', 'add_elt_picture_pre');

function add_elt_picture_pre() {
    global $template;
    $template->set_prefilter('picture', 'add_elt_picture_preT');
}

function add_elt_picture_preT($content, &$smarty) {

   $search = '';
   
   $repla='';
     
    return preg_replace($search, $repla , $content);

}


You love Piwigo so don't hesitate to participate, learn more on the "Contribute to Piwigo" page. If you don't have much time for contribution, you can also help the project with a donation.

Offline

 

#4 2017-08-13 07:45:11

cgcarter
Member
2017-08-09
14

Re: Change Contact Form plugin to popup form over top of picture page

Thanks for the help!  This is a solid lead, and running it from the contactform plugin main.inc.php did indeed remove the image in picture.tpl.  I guess I'm just not sure how this code works.

How do I modify this to include the contact form into picture.tpl?  Am I supposed to give values to these?
 
$search = '';
   
$repla='';

Like do I tell it a line of code to search and then replace? Sorry, I'm a tad lost...

Thanks!

Last edited by cgcarter (2017-08-13 08:13:34)

Offline

 

#5 2017-08-13 22:28:49

cgcarter
Member
2017-08-09
14

Re: Change Contact Form plugin to popup form over top of picture page

Ok, after some research into the the function pre_replace(), I can see how this is supposed work.  The next question though is, what, exactly needs to get inserted into picture.tpl for it to fully load the contact form template?

Offline

 

#6 2017-08-14 20:39:01

cgcarter
Member
2017-08-09
14

Re: Change Contact Form plugin to popup form over top of picture page

Just to update anyone reading this - I've tabled this project because I felt that simply adding a mailto link via javascript into the index.tpl and picture_nav.tpl templates was sufficient.  It's not the perfect solution, but it works for now, at least until I learn more about how all this works.

Offline

 
  •  » Extensions
  •  » Change Contact Form plugin to popup form over top of picture page

Board footer

Powered by FluxBB

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