I have created a snippet name “abc” and added the below code:
{exp:member:custom_profile_data}
{exp:query sql="SELECT md.m_field_id_1 AS custom_field FROM exp_member_data AS md WHERE md.member_id = '{member_id}'" }{custom_field}{/exp:query}
{/exp:member:custom_profile_data}
When we are accessing this snippet “abc” in tempalte file it returns the value with both side whitespace.
Please check and advise
Thanks
I’m not reproducing. When I format the snippet like this:
{exp:member:custom_profile_data}{exp:query sql="SELECT md.m_field_id_1 AS custom_field FROM exp_member_data AS md WHERE md.member_id = '{member_id}'" }{custom_field}{/exp:query}{/exp:member:custom_profile_data}
And then render it in a template like this:
test{test_snippet}test
There is no whitespace on either side of the snippet.
Thanks Kevin, Now it is fixed. We have seen lots of spaces or newline in snippet editors. We have removed it and added the code all on one line.
I was facing another issue to snippet if condition
My snippet “test_snippet” return to 10
If I use below code in “_header” template then it is not checking conditional
if{test_snippet == '10'} {/if}
We have parse it in below way then it works
{embed="ssi/_header" snippet_parse="{test_snippet}"}
Now in header template we have applied below code
if{snippet_parse == '10'} {/if}
then it is working
Hi Kevin
We have found following recommend, not wrapping variables in braces ({}) for example, do this:
{if my_snippet == "hello world"}
instead of these:
{if {my_snippet} == "hello world"}
{if "{my_snippet}" == "hello world"}
EE refrence url is https://docs.expressionengine.com/latest/templates/conditionals.html
Please check
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.