1

I'm trying getting to grips with Expression Engine. Specifically passing custom field information to a master layout

I have created two template groups. One for the overall layout including the header and footer and one to control a specific channel.

I have custom fields for the channel. Including one called "description" that I want to be able to pass back to the overall header layout. This is what I have from looking at the documentation but it doesn't work - the variable {timeline_item_description} isn't getting passed to the header. Looking at the code below what am I doing wrong?

Channel index template:

{layout:set name="desc"}{timeline_item_description}{/layout:set}

The Header layout template:

<meta property="og:description" content="{layout:desc}"
  • Dumb question. Is the layout:set inside the channel:entries variable pair? – Robson Sobral May 9 '14 at 12:55
  • 1
    No it is not inside the channel:entries variable pair – Dan Lee May 9 '14 at 13:05
2

If your trying to pass a simple value to your layout, you can set it on the layout tag. For example:

{layout="pages/.layout" body_class="contact"}

But custom fields variables need to be parsed by the channel:entries variable pair. This is the reason for the tag layout:set.

{exp:channel:entries [...]}
    {layout:set name="desc"}{timeline_item_description}{/layout:set}
{/exp:channel:entries}

By this way, its value is passed to the layout template.

| improve this answer | |
0

I believe what you describe should work.

  1. I take it you have a {layout="site/.header_layout"} tag in your children (channel index template) as well, and that the path to the template_group/template is correct ?
  2. I suppose that you can print out {timeline_item_description}in your children template and that it works
  3. Could you try the following just to be sure ?

Channel index template:

{layout="site/.header_layout"}    
{layout:set name="desc" value="{timeline_item_description}"}

Header Layout template

<meta property="og:description" content="{layout:desc}" />
| improve this answer | |
  • Looking at the source when I do that shows '<meta property="og:description" content="{timeline_item_description}" />' Doesn't seem to work. – Dan Lee Apr 9 '14 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.