Announcement

  •  » Extensions
  •  » Access local Piwigo config in SMARTY template

#1 2018-11-25 13:20:27

reisi007
Member
2018-11-16
16

Access local Piwigo config in SMARTY template

Hi,

I want to extend my template. I have $conf['test'] = "Hello World!" in my local configuration.

What can I use to access this variable in a .tpl file?

Thank you!


Piwigo version: 2.9.4

Offline

 

#2 2018-11-25 20:06:51

nicolas
Former Piwigo Team
2004-12-30
1232

Re: Access local Piwigo config in SMARTY template

reisi007 wrote:

Hi,

I want to extend my template. I have $conf['test'] = "Hello World!" in my local configuration.

What can I use to access this variable in a .tpl file?

Thank you!


Piwigo version: 2.9.4

You should do something like the following code :

Code:

$template->assign('my_conf_test_variable', $conf['test']);

And you can of course choose the key you want for your variable instead of my_conf_test_variable

Last edited by nicolas (2018-11-25 20:07:13)

Offline

 

#3 2018-11-25 21:36:56

reisi007
Member
2018-11-16
16

Re: Access local Piwigo config in SMARTY template

Hi,

Thanks for your answer.

This seems to work, but my_conf_test_variable is not printed. Can you please assist in how to print this variable, which contains HTML tags..?

The solutions I found didn't work...

Offline

 

#4 2018-11-26 08:41:16

nicolas
Former Piwigo Team
2004-12-30
1232

Re: Access local Piwigo config in SMARTY template

reisi007 wrote:

Hi,

Thanks for your answer.

This seems to work, but my_conf_test_variable is not printed. Can you please assist in how to print this variable, which contains HTML tags..?

The solutions I found didn't work...

You add the smarty tag :

Code:

{$my_conf_test_variable}

Offline

 

#5 2018-11-26 22:06:52

reisi007
Member
2018-11-16
16

Re: Access local Piwigo config in SMARTY template

Hi,

Thanks for your reply, but I did this as told. Here my code

Code:

add_event_handler('loc_end_element_set_unit', 'reisisot_mainpage'); 

function reisisot_mainpage(){
  global $template;
  $test = '<p>Hallo!</p>';
  
 $template->assign('reisishotMainpagetext', $test);
}

I also tried it with add_event_handler('combinable_preparse' ...


My template code is:
 

Code:

{$reisishotMainpagetext}
 <!-- Test 2 {if isset($reisishotMainpagetext)} VAR IS SET {else} VAR IS NOT SET {/if}-->

The text, which is printed in the HTML is:

Code:

 <!-- Test 2  VAR IS NOT SET -->

Thanks for your help!

Last edited by reisi007 (2018-11-26 22:08:06)

Offline

 

#6 2018-11-26 22:12:06

flop25
Piwigo Team
2006-07-06
7037

Re: Access local Piwigo config in SMARTY template

probably not the right event

mainpage_categories.tpl
loc_end_index_category_thumbnails
thumbnails.tpl
loc_end_index_thumbnails
etc


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

 

#7 2018-11-26 22:13:14

reisi007
Member
2018-11-16
16

Re: Access local Piwigo config in SMARTY template

@flop25: Is there a list with all events?

PS: this code is in the index.tpl file

Last edited by reisi007 (2018-11-26 22:13:57)

Offline

 

#8 2018-11-26 22:23:35

flop25
Piwigo Team
2006-07-06
7037

Re: Access local Piwigo config in SMARTY template

yourpiwigo/tools/triggers_list.php


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

 

#9 2018-11-27 18:14:26

reisi007
Member
2018-11-16
16

Re: Access local Piwigo config in SMARTY template

Thanks for providing me with the list of all triggers.

Using

Code:

loc_begin_index

everything works like a charm.

Offline

 
  •  » Extensions
  •  » Access local Piwigo config in SMARTY template

Board footer

Powered by FluxBB

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