We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Send entry_id to an embed outside of a {exp:channel:entries) tag

How Do I?

Joe's avatar
Joe
3 posts
10 months ago
Joe's avatar Joe

I am trying to send the entry_id to an embedded HTML template. {layout="_embeds/_html-layout" entry_id='613' test="test"}

It works when I use a hard-coded entry ID, but it doesn’t work when I use the following. {layout="_embeds/_html-layout" entry_id='[entry_id}’ test=”test”}

What must I do to send the entry ID to the layout template?

       
Rob Allen's avatar
Rob Allen
3,105 posts
10 months ago
Rob Allen's avatar Rob Allen

What are you trying to do with the entry ID?

       
Joe's avatar
Joe
3 posts
10 months ago
Joe's avatar Joe

The entry_id is sent to seo_lite to produce the correct HYML title tag. The code that calls seo_lite is in the layout template. If I put the layout template inside the {exp:channel:entries} ta, I get a blank screen.

       
Rob Allen's avatar
Rob Allen
3,105 posts
10 months ago
Rob Allen's avatar Rob Allen

Ah OK I’d do it a different way using a layout variable.

So in your channel entries tag use a layout:set tag to set the entry ID value:

{exp:channel:entries channel="yourchannel" ...}

<!-- get the entry ID and set the layout:set tag with name 'the_id'-->
{layout:set name="the_id"}{entry_id}{/layout:set}

<!-- entry fields-->
<h1>{title}</h1>

...etc

{/exp:channel:entries}

The layout:set tag essentially passes its value to the layout template to use as you need.

Then, assuming your SEO_lite tag is in your layout template, call the layout set value like this:

{exp:seo_lite entry_id="{layout:the_id}"}

Does that help?

       
Joe's avatar
Joe
3 posts
10 months ago
Joe's avatar Joe

Sorry it doesn’t.

{layout="_embeds/_html-layout" entry_id="{entry_id}”}

{exp:channel:entries channel="products|projects" status="not closed" limit="1" disable="member_data|category_fields"}

That is the top of my entry template. Notice the layout call is outside the exp:channel:entries tag. If I use that code, the entry_id sent to the layout is blank. If I hard code the number, as in “{layout="_embeds/_html-layout" entry_id="613"}”, it works with that entry id. I need to know how to access the entry_id outside the exp:channel:entries tag.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.