1

I have a channel with 4 relationship fields and each entry can be related to one or two relationship fields. and I hide unnecessary fields using ENTRY TYPE(http://devot-ee.com/add-ons/entry-type) field type. In the template I am fetching the channel entries using fixed_order and based on entry-type I am embedding a template with entry field values..all field values comes fine except relation fields and I am not able to understand why it directly show relationship field tags directly. My expression looks something like this

{exp:stash:set name="home_page_blocks"}
  {exp:channel:entries channel="pages"}
    {select_left_blocks}{select_left_blocks:entry_id}|{/select_left_blocks}
  {/exp:channel:entries}
{/exp:stash:set}

{exp:channel:entries channel="blocks" dynamic="no" parse="inward" fixed_order="0|{exp:stash:get name='home_page_blocks'}" }
{exp:switchee variable = "{select_block_type}"}

{case value="news_article_block"}
    {title} || {related_news_article}{related_news_article:entry_id}{/related_news_article}
{/case}

{case value="case_article_block"}
    {title} || {related_case_article}{related_case_article:entry_id}{/related_news_article}
{/case}
{/exp:switchee}     
{/exp:channel:entries}  

Now this expression outputs

Entry title one || {related_news_article}{related_news_article:entry_id}{/related_news_article}

and I am not able to understand whats going wrong here,can anyone please help me out here

Cheers Nisar

1

Lets tidy this up:

{exp:stash:set name="home_page_blocks" parse_tags="yes" trim="yes"}//Trim removes whitespace
    {exp:channel:entries channel="pages" backspace="1"} // Remove last '|'
     {select_left_blocks}{select_left_blocks:entry_id}|{/select_left_blocks}
    {/exp:channel:entries}
{/exp:stash:set}

This should now output a list like "33|23|35" - test, test, test your output of this list as if it's broken here, the rest will fail.

Next you'll need to feed that to your other query:

{exp:stash:parse}//Wrap this in a parse block so its processed after the set above
  {exp:channel:entries channel="blocks" dynamic="no" fixed_order="0|{exp:stash:get name='home_page_blocks'}" }
  {exp:switchee variable = "{select_block_type}" parse="inward"} //Parse inward lives here

  {case value="news_article_block"}
    {title} || {related_news_article}{related_news_article:entry_id}{/related_news_article}
  {/case}

  {case value="case_article_block"}
    {title} || {related_case_article}{related_case_article:entry_id}{/related_news_article}
  {/case}
  {/exp:switchee}     
{/exp:channel:entries}
{/exp:stash:parse}

Basically we've trapped your info in the required format (white space plays havoc with pipe delimited lists). Added a few stash additional stash calls and wrapped the "get" function in a parse to ensure it runs after the set (EE parse order takes some thinking/reading).

This is all untested and based on my own experience - it may or may not work as is, my code may not be perfect – but the approach is solid. You'll have to experiment your way through it. OR sit tight, be slack and wait for someone else to solve it for you ;-)

Have fun, try some different tags and see what results you get - think of it as learning!

| improve this answer | |
  • Also of note, the opening and closing relationships in the second case do not match: {related_case_article}{related_case_article:entry_id}{/related_news_article} – Jeremy Gimbel May 13 '14 at 2:51
  • Thanks a bunch stuartmcd69..your suggestion worked out and sorry for not preparing the question in an untidy manner.. – Nisar Uddin May 13 '14 at 13:30

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.