Hi to everyone.
First of all I want to say that I have some experience with EE but I still consider myself a noob because I’m not using it so frequently.
I have a problem with executing php code when script is located in some xy directory.
Installed and enabled php in 5.3.2 and 6. Tested code in a template with EE tags and on template without EE tags. I always get an error. Tried on localhost environment and web server, always get error. Error is the same having tags or not having tags in template.
To be sure that php code and script is ok, created simple index.php page and code is executing script without any problems. But when I copy / paste that code in EE template I get only error.
Tried some simple php for displaying date, time etc. and that runs smoothly in every version of EE.
My conclusion is that there is a problem when you want to use php code in template but code need script to be included from different directory.
Maybe I’m wrong and that is not a problem, just I don’t know how to use that feature correctly.
I hope that someone can give some advice, or maybe even provide a solution 😊
Error is:
You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}.
Parser State: Unexpected ‘(’ (LP); expected RD in Template “test/index” on line 15.
Br,
An Invalid conditional usually means your syntax isn’t correct, often missing a curly brace {}, or missing {/if} (as it says).
It really needs someone/yourself to go through the code using a fine tooth comb to spot whatever may causing it.
You might want try adding your code in small chunks, then when it fails that can help narrow down where to look.
I would also avoid using php in a template if at all possible- roll a plugin, it won’t take much longer. Use https://ee-addon-generator.triplenerdscore.xyz/ and it will give you all of the base files in just a couple of seconds.
Also when using php in a template, be careful about parsing on input vs output- it’s going to change the behavior. If you’re using tags in your php, they may not be what you think they are.
@Rob Allen
Thank you for suggestion, but I get same Invalid conditional even when I don’t use tags. Just pure php code inside template. Because of that does not make any sense. Tried on EE 5.3.2. and in EE 6 beta. Same result.
But when I try that same php code in simple xyzpage.php (or xyzpage.php with html tags) file outside EE environment (on localhsot WAMP or web server), works great. It seems that EE has some problem with processing that code or executing php script from different directory.
Also tried executing chunks and I get error after inserting code for executing script.
I would now what to look for if that script does not work like a standalone code. But like I said, outside EE environment script works great.
@Robin Sowell
Thank you for your suggestion, that php script is little bit complicated and it’s not mine. To be precise I bought it because I don’t have time and will to create and maintaine something like that because that script is for displaying social media content from FB page, instagram, twitter etc. And I want to preserve option for update from original author.
Main purpose of that script is just to display social media channels that you have on your web page but it has backend where user can simply configure everything by himself.
P.S. EE 6 beta admin / user interface looks great 😊
Br,
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.