I have been developing a few plugins and I have found the API to be useful and convenient, however thre is a problem.
When i try to pass a variable through the parameter list is comes up null in PHP.
Template example (intro is a custom field in the weblog “my_weblog”):
{exp:weblog:entries weblog="my_weblog"}
{exp:my_plugin:my_method my_variable="{intro}"}
{/exp:weblog:entries}
PHP usage:
$my_variable = $TMPL->fetch_param('my_variable');
In the above usage the variable
$my_variable
would be empty.
Moved from Tech Support by Moderator
Hi hereward,
Are you positive that {intro} is being parsed to what you expect?
Try something like:
{exp:weblog:entries weblog="my_weblog"}
Variable: {intro}
{exp:my_plugin:my_method my_variable="{intro}"}
{/exp:weblog:entries}
And have the plugin return (or better yet var_dump()) the variable.
What do you see?
Actually the entries tag is a weblog module tag, and does not need that parameter to be parsed before plugin tags contained within the entries tag, Erin. That parameter is used when you have multiple nested plugin tags that you need to outer to be parsed first. the_butcher’s advice is correct in this case, hereward.
Hi hereward, Are you positive that {intro} is being parsed to what you expect? Try something like:And have the plugin return (or better yet var_dump()) the variable. What do you see?{exp:weblog:entries weblog="my_weblog"} Variable: {intro} {exp:my_plugin:my_method my_variable="{intro}"} {/exp:weblog:entries}
Hi thanks for your reply. i have been away for a while. I am not sure what you are driving at there, but I can assure you that the variable has valid data in it.
In fact I was able to get the plugin working using the variable as parsed data rather than as a plugin parameter, so I think I have already addressed this question.
example:
{exp:weblog:entries weblog="my_weblog"}
{exp:my_plugin:my_method}
{intro}
{/exp:my_plugin}
{/exp:weblog:entries}
The problem is, when the variable is passed as a parameter to the plugin it becomes null when the PHP executes the code.
As a final test … does anybody have a working example of ANY custom plugin that can receive variables as parameters? If anyone can demonstrate that such a beast exists i would eat my hat.
Thanks (:
Bienvenido al futuro de la comunicación con ChatGPT Gratis - lo último en chatbot potenciado por IA en GPTGratis.net. Todos sabemos que la comunicación ha evolucionado drásticamente en la última década y en GPTGratis.net, estamos orgullosos de estar a la vanguardia de esta emocionante revolución. Creemos que el poder de la IA puede mejorar las interacciones humanas, haciéndolas más eficientes, agradables y cómodas. Y eso es exactamente lo que ChatGPT Gratis hace por ti.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.