Stash
ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6
Back to this add-on's main page
View Other Add-ons From Mark Croxton
Channel field value to php varibale value
Support Request
georgejr
|
Posted: 26 January 2016 08:49 AM |
|
|
|
Hi,
My problem is a following. I have channel field value for egz 7.
This comes from the channel.
In the template I have a php code, which calls a rest api url:
$pid="{stash:pg_product}"; $url="http://myapiurl.com/".$pid."";
$t=CallAPI('GET', $url);
It seems the url when I echo or var_dump it looks like this:
http://myapiurl.com/7
but it the function looks like this: http://myapiurl.com/{stash:pg_product}
Tried to turn to php parse as output, but then all my php code looks like:
<!--?php $pid="{stash:pg_product}"; $url="http://myapiurl.com/".$pid."";
$t=CallAPI('GET', $url); ?-->
What"s wrong? Tried to embed the full code in a sub template, but the result is the same:(
|
|
|
Mark Croxton
|
Posted: 26 January 2016 09:11 AM |
# 1
|
|
Developer
|
Stash embeds won’t parse PHP, and this is by design. PHP in templates, especially Stash templates, has the potential to be dangerous and should be considered an anti-pattern.
Please create a simple plugin instead:
https://docs.expressionengine.com/latest/development/plugins.html
|
|
|