Member
Member
ctdlg   2024-06-16, 14:28
#1
I try to understand Zenphotos macros.

Following this page
https://www.zenphoto.org/news/content-macros/
I wrote a php macro file, enabled it in the extensions admin page.

I get a blank page because of line
'owner'=>'mymacro.php';

and with
'owner'=>'mymacro.php',
My Hello World is not displayed (using [ HELLOWORLD My ] )
End of page is not displayed too.

Using [ HELLOWORLD ] displays in red 1 parameter is missing, but page is fully displayed.

[ HELLOWORLD 'My' ] does not work too.
So, I am a bit lost.

Administrator
Administrator
acrylian   2024-06-16, 16:29
#2
Without the full code it will be hard to tell. What does the debuglog say? (that is the first you have to look!).

If you have the spaces before/after the brackets it is probably just that. Those are only there in the doc - as noted - to make sure ZP does not exectute them. So ` [HELLOWORLD My]`.

I referenced it on the other topic but this is a quite simple macro plugin you also can use as a guide:
https://github.com/acrylian/zp_mapembed
Member
Member
ctdlg   2024-06-16, 18:23
#3
My php file is a copy of code found here :
https://www.zenphoto.org/news/content-macros/ :
<pre>[code]
<?php
/** Macro de test
*
*

* Fichier php dans le répertoire plugins, et activé.
* */
$plugin_author = "Me";
$plugin_version = '0.1';
$plugin_is_filter = 5|THEME_PLUGIN|ADMIN_PLUGIN;
zp_register_filter('content_macro','mymacro');
function mymacro($macros) {
$macros['HELLOWORLD'] = array(
'class'=>'expression',
'params'=>array('string'),
'value'=>'getHelloWorld($1);',
'owner'=>'basic',
'desc'=>gettext('%1 = Text before')
);
return $macros;
}
function getHelloWorld() {
return $beforetext.'Hello World';
}
?>
</pre>[/code]
And error log :
<pre>[code]
{885:Sun, 16 Jun 2024 18:14:18 GMT} Zenphoto v1.6.3
AVERTISSEMENT : Undefined variable $_zp_db dans /DonneesMsi/Sites/clatique/multimedia/zp-core/functions/functions.php à la ligne 2727
applyMacros called from getCodeblock (template-functions.php [4365])
from printCodeblock (template-functions.php [4379])
from include (pages-aide.php [33])
from include (index.php [128])
from index.php [56]
{885:Sun, 16 Jun 2024 18:14:18 GMT}
ERREUR : Call to a member function quote() on null dans /DonneesMsi/Sites/clatique/multimedia/zp-core/functions/functions.php à la ligne 2727
</pre>[/code]

Your macros are ok :
<pre>[code]
[ZENPHOTO_VERSION]
[CODEBLOCK 2]
</pre>[/code]
work as expected
Administrator
Administrator
acrylian   2024-06-17, 07:13
#4
The code looks actually correct, althouth the macro class probably should be "function" instead of "expression".

Thanks you just found an error. There was a globla declaration missing. Should be fixed in the 1.6.4 support build. 1.6.4 will probably be release later today.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.