Announcement

  •  » Extensions
  •  » How to use category ID for my own plugin

#1 2018-10-06 11:20:16

HarryF
Member
2013-09-25
27

How to use category ID for my own plugin

Hello,

at the moment I'm trying to create my first own plugin for Piwigo and I was already quite successful with the addition of image information on the image page as well as on the corresponding admin page.

But now I would like to provide additional information to category pages. As on the image page I tried to add additional fields to the admin page with the help of the copyright example. But for the planned functionality I need the category ID. Unfortunately I didn't find out which variable it contains or if it is passed at all (but I think it is).

Can anyone give me a hint about this? Are there more helpful documentations than the tutorials for copyrights anywhere?

I'd appreciate any help and say thank you in advance!
Harry

Piwigo 2.9.4
Linux
PHP: 7.2.10-0ubuntu0.18.04.1 (Info anzeigen) [2018-10-06 11:12:51]
MySQL: 5.5.5-10.1.34-MariaDB-0ubuntu0.18.04.1 [2018-10-06 11:12:51]
ImageMagick 6.9.7-4

Offline

 

#2 2018-10-07 20:41:02

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

Re: How to use category ID for my own plugin

Hi :-)

Code:

global $page;
if (!empty($page['category']['id']))
{
  $category_id = $page['category']['id'];
  // ****** your code ********     
}

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

 

#3 2018-10-07 22:29:21

HarryF
Member
2013-09-25
27

Re: How to use category ID for my own plugin

Thanks a lot. That's what I needed I guess. I'l try it next days.

Offline

 

#4 2018-10-09 10:13:18

HarryF
Member
2013-09-25
27

Re: How to use category ID for my own plugin

Hi again!

I only thought, that this would solve my problem but it didn't. However, after some experiments I found out that the category id can be found in $page['cat_id'].

Could you please help in another point: What are the numbers in the event handler definition for? I have the feeling ;-) they could possibly cause another problem I have hat the moment.

Code:

add_event_handler('loc_begin_admin', 'PMV_set_prefilter_cat_modify', 50);
add_event_handler('loc_begin_admin_page', 'PMV_cat_modify_submit', 45);

Sorry for the maybe silly questions but I'm no programmer but I have a bit more than base knowledge in PHP programming and I'm still learning ;-) .

Thanks
Harry

Offline

 

#5 2018-10-09 23:07:30

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

Re: How to use category ID for my own plugin

Hi :-)

It's order execute

if you,ve

add_event_handler('loc_begin_admin_page', 'PMV_cat_modify_submit', 45);
add_event_handler('loc_begin_admin_page', 'PMV_cat_modify_submit2', 46);
add_event_handler('loc_begin_admin_page', 'PMV_cat_modify_submit3', 47);

piwigo executed PMV_cat_modify_submit after PMV_cat_modify_submit2 after PMV_cat_modify_submit3


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

 
  •  » Extensions
  •  » How to use category ID for my own plugin

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact