Announcement

  •  » Extensions
  •  » Create a Piwigo extension for dumies

#1 2009-02-24 10:52:40

alxkaz
Member
2008-11-12
13

Create a Piwigo extension for dumies

Hi,

I'd like to know if there is a tutorial or something to learn how to create a piwigo extenstion for the 2.0? I searched in the forum and didn't find anything. So is there something to help newbies like me?

thank you

Offline

 

#2 2009-02-25 00:04:02

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: Create a Piwigo extension for dumies

There are several kinds of extensions : templates, themes, languages, tools and plugins. As the 3 first are quite easy to understand, "tools" can be anything you want, I suppose you're asking about plugins.

As far as I know, the most complete guide is [wiki] Managing Plugins. This link currently goes to the old phpwebgallery.net website, and should be updated soon.

We need some extra documentation about "how to write a plugin" because to tell the truth, a plugin can do quite anything you want :-) Once you will have the whole picture in mind don't hesitate to ask more specific questions, this way we will improve the existing documentation.

Offline

 

#3 2009-04-25 14:40:23

AdamQuadmon
Member
Italy: Naples, Rome, Perugia
2009-04-25
14

Re: Create a Piwigo extension for dumies

I was looking for some implementations.

E.G.: adding mootools javascript framework and related scripts in some page

I've follow the link to the old documentation and I try the simple element adding for the header

Code:

function my_add()
{
  global $template;
  $url_to_me = get_root_url().'plugins/adam/';
  
  $template->assign_block_vars('head_element', array (
    'CONTENT' => '<link rel="stylesheet" type="text/css" href="'.$url_to_me.'style.css">'
    ));
  
  $template->assign_block_vars('head_element', array (
    'CONTENT' => '<script type="text/javascript" src="'.$url_to_me.'mootools.js"></script>'
    ));
}
 
add_event_handler('loc_end_page_header', 'my_add' );

but result is Call to undefined method Template::assign_block_vars()

I suppose the Template method assign_block_vars is obsolete

where I can find a list of class and methods avalible for the latest version of PWG, and a list of event handlers?

I need in particular how to discriminate a page from another (the category page, the picture page, etc)

Excuse my english, my french is worse


Odi et Amo, quare id faciam, fortasse requiris? Nescio, sed fieri sentio et excrucio

my personal gallery

Offline

 

#4 2009-04-25 15:28:00

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

Re: Create a Piwigo extension for dumies

the template engine has changed, now we use smarty : http://www.smarty.net/docs.php

what you want to do is close to the paMOOramics plugin, you should look inside it ([extension by repie38] paMOOramics)
(for me, it's the way I understood the new template)

Last edited by repie38 (2009-04-25 15:28:21)

Offline

 

#5 2009-04-25 15:35:17

VDigital
Former Piwigo Team
Paris (FR)
2005-05-04
17680

Re: Create a Piwigo extension for dumies

"Template method assign_block_vars is obsolete" that's true.
Piwigo adopted Smarty.
http://www.smarty.net/
You will discover all the documentation you are expecting there.

About the "list of class and methods avalible for the latest version of PWG, and a list of event handlers?"
The event tracer is a developer tool, it is a distributed plugin.
Activate this one.
And have a look on the link after the submit button.
"Click here to see a complete list of actions and events trigered by this PWG version."

"I need in particular how to discriminate a page from another (the category page, the picture page, etc)."
Maybe you should undestood before the template extension logic.

Enjoy.

Latter: Partly duplicate, thanks to repie38


Piwigo.com: Start and run your own photo gallery. Signup and get 30 days to try for free, no commitment.
8-)

Offline

 

#6 2009-04-25 15:49:51

AdamQuadmon
Member
Italy: Naples, Rome, Perugia
2009-04-25
14

Re: Create a Piwigo extension for dumies

thanks for the quick reply, now I study the plugin, I know Smarty a little...


Odi et Amo, quare id faciam, fortasse requiris? Nescio, sed fieri sentio et excrucio

my personal gallery

Offline

 

#7 2009-04-25 17:20:12

AdamQuadmon
Member
Italy: Naples, Rome, Perugia
2009-04-25
14

Re: Create a Piwigo extension for dumies

It was very very simple:

Code:

<?php

if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');

class adam
{
  function adam_load ($content)
  {
    global $template,$picture,$page;
    
    $template->append('head_elements',
    '<script src="plugins/adam/mootools-1.2.1-core.js" type="text/javascript" charset="utf-8"></script>
    <script src="plugins/adam/mootools-1.2-more.js" type="text/javascript" charset="utf-8"></script>
    <script src="plugins/adam/script.js" type="text/javascript" charset="utf-8"></script>');
  }
}

$obj = new adam();

add_event_handler('render_element_content', array(&$obj, 'adam_load'),41,2);

?>

but what's the 3rd and 4th params of add_event_handler? (41,2)


Odi et Amo, quare id faciam, fortasse requiris? Nescio, sed fieri sentio et excrucio

my personal gallery

Offline

 

#8 2009-04-25 17:41:27

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

Re: Create a Piwigo extension for dumies

The third parameter (optional) is the priority... default is 50.
If some plugins use default priority for an handler, and your function must be called before, you must use inferior priority (40, 30, etc...)
If your function need to be called after, you know what to do ;-)

The 4th parameter (optional) is the number of arguments for your function.
If your function need 2 or more arguments, you must fill this parameter.

PS: excuse my english too ;-)

Last edited by P@t (2009-04-25 17:43:29)


P@t

Offline

 

#9 2009-04-25 18:13:52

AdamQuadmon
Member
Italy: Naples, Rome, Perugia
2009-04-25
14

Re: Create a Piwigo extension for dumies

At the beginning I was afraid that no good docs are provided with piwigo, but the forum is powerfull!!!!

Thanks a lot!

My gallery is cooming soon... so I can share with you my knowlege.

I came from Menalto Gallery, but understanding and customizing Piwigo is simpler, and what about the default skin? Is Amazing!


Odi et Amo, quare id faciam, fortasse requiris? Nescio, sed fieri sentio et excrucio

my personal gallery

Offline

 

#10 2009-04-25 21:00:49

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

Re: Create a Piwigo extension for dumies

Don't forget to let a message in introductions and testimonials when your gallery will be ready...
And do not hesitate to ask team if you have another questions ;-)


P@t

Offline

 

#11 2009-05-05 17:24:06

AdamQuadmon
Member
Italy: Naples, Rome, Perugia
2009-04-25
14

Re: Create a Piwigo extension for dumies

The gallery is done.

You can find it at www.lucianoamodio.it/portfolio


Odi et Amo, quare id faciam, fortasse requiris? Nescio, sed fieri sentio et excrucio

my personal gallery

Offline

 

#12 2009-05-15 22:26:53

mathiasm
Former Piwigo Team
2006-02-06
2650

Re: Create a Piwigo extension for dumies

AdamQuadmon wrote:

The gallery is done.

You can find it at www.lucianoamodio.it/portfolio

You should set the default language to italian, it will look even better. Currently, default is french and it looks weird.

Regards.

Offline

 

#13 2009-05-15 22:52:31

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: Create a Piwigo extension for dumies

mathiasm wrote:

You should set the default language to italian, it will look even better. Currently, default is french and it looks weird.

I think Italian was set as default language, but as $conf['browser_language'] is set to true by default, you mathiasm and I see AdamQuadmon gallery in French.

Offline

 

#14 2009-05-16 07:50:15

VDigital
Former Piwigo Team
Paris (FR)
2005-05-04
17680

Re: Create a Piwigo extension for dumies

That's true!  ( by $conf['browser_language'] )


Piwigo.com: Start and run your own photo gallery. Signup and get 30 days to try for free, no commitment.
8-)

Offline

 

#15 2009-05-16 07:57:42

VDigital
Former Piwigo Team
Paris (FR)
2005-05-04
17680

Re: Create a Piwigo extension for dumies

AdamQuadmon wrote:

The gallery is done.

You can find it at www.lucianoamodio.it/portfolio

From my point of view, it is one of the best example what anyone can do with Piwigo.
Many thanks.

(I will email you in few days).


Piwigo.com: Start and run your own photo gallery. Signup and get 30 days to try for free, no commitment.
8-)

Offline

 
  •  » Extensions
  •  » Create a Piwigo extension for dumies

Board footer

Powered by FluxBB

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