I’m trying to get an entry from the partners channel based on the value stored in the super_cookies. It isn’t working. Can someone show me the correct way of doing this please?
Here’s the code:
{if {exp:super_cookies:get name="partner_id"} }
{exp:channel:entries channel="partners" entry_id="{exp:super_cookies:get name='partner_id'}" limit="1" }
<div class="col">
{brand_logo}
</div>
<div class="col mbr_contact">
<div class="member_title_header">{title}</div>
{if partner_phone}{partner_phone} <br>{/if}
{if contact_email}<a href="mailto:{contact_email}target=_blank" rel="noopener">{contact_email}</a><br>{/if}
{if company_website}<span><a href="http://{company_website}target=_blank" rel="noopener">Visit Website</a></span>{/if}
</div>
{/exp:channel:entries}
{/if}
Strange - the template debugger is showing an odd value that isn’t the value in the cookie.
So, now I know why it’s not working. See the attached screenshot, the entry_id value should be 413. Not that long string of random characters.
Can I simply use PHP to read the cookie instead of using the exp:super_cookies addon?
So that means that something with the add-on is properly throwing an error or is not parsing correctly. If you know PHP, you can probably track it down in the add-on’s file.
You may also try adding parse="inward"
to see if that’s the issue. So it would look like {exp:channel:entries channel="partners" entry_id="{exp:super_cookies:get name='partner_id' parse='inward'}" limit="1" }
You can enable PHP on the template and handle it that way if you want, but we typically recommend against enabling PHP unless needed. It’s often just as simple to create a super quick add-on to return the value you want instead of risking security issued by enabling PHP.
Few helpful links:
Hope this helps.
fyi. I just had a few minutes to test on a local install with the default theme. For me, I needed to add parse="inward"
to the exp:channels
tag.
So it looks like this {exp:channel:entries channel='blog' limit='1' entry_id="{exp:super_cookies:get name='mycookie'}" dynamic="no" parse="inward"}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.