ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Passing field names/variables inside related entries tag

March 30, 2011 4:57pm

Subscribe [3]
  • #1 / Mar 30, 2011 4:57pm

    fensterbaby

    289 posts

    This might seem like a Channel Images issue but it’s really a related entries question.

    I have a relationship set up and it’s working. But within the relate entries tags I am doing search by category on the Channel Images field.

    I want to set the parameter of CI as category={trip_name} where trip_name is a field in the Trips channel. But I can’t use that field name inside the related entries tag.

    How can I pass this value?

    
    									
  • #2 / Mar 31, 2011 7:28am

    Greg Salt

    3988 posts

    Hi fensterbaby,

    That should be available. What does the variable trip_name output if you put it on its own right after the channel entries opening tag?

    Cheers

    Greg

  • #3 / Mar 31, 2011 1:53pm

    fensterbaby

    289 posts

    Hi fensterbaby,

    That should be available. What does the variable trip_name output if you put it on its own right after the channel entries opening tag?

    Cheers

    Greg

    If I do that it returns the value of {trip_name}

    and if I hard code a value for {trip_name} inside the related tags it works.

    So that field is unavailable inside the related tags.


    Anybody have a clue about this? This is the last issue to solve on this project I’m trying to get out the door. I have exhausted my ability to troubleshoot this.

  • #4 / Mar 31, 2011 10:42pm

    fensterbaby

    289 posts

    Some one suggested that it’s a parsing order issue and that part of the code needs to be in an embed

    Does that help?

    I tried some stuff along those lines but nothing worked. If anything it made matters worse

    I can’t be the first person with this issue. Trying to get this site out the door and this problem is holding it up.


    Anyone?

  • #5 / Apr 01, 2011 5:49pm

    fensterbaby

    289 posts

    any tech support online that could take a look at this?

    Thanks

    GF

  • #6 / Apr 01, 2011 10:25pm

    Brett Gullan

    70 posts

    Hi fensterbaby,

    That’s a tough one! I can think of a couple of options—none of them pretty—that might work.

    1) Use an embed to pass the values you need. There’ll be some duplication but it should work. Try this:

    {exp:channel:entries channel="trips" limit="1"  status="open" } 
            {embed="some/template" entry_id="{entry_id}" trip_name="{trip_name}"}
    {/exp:channel:entries}

    ... and in your embed:

    
    
    

    2) Use a third-party plugin to store “state” within the page, something like String (http://www.emarketsouth.com/add-ons/string-plugin/) or NSM Transplant (http://ee-garage.com/nsm-transplant). Using the String plugin, you could try something like this:

    
    
    

    3) A further option might be to replace your relationship with a Playa field, which would open up a number of easier/cleaner options.

    HTH

  • #7 / Apr 01, 2011 11:23pm

    fensterbaby

    289 posts

    Brett, you’re a life saver.

    I had tried Option 1 earlier but it just wouldn’t work.

    I tried it again looking at your example and now it woooooorks.

    Must have been something funked up with my code cause that’s the ticket

    Thank you sooooo much

    I know it takes time to sit and type out solutions like that when you have your own projects calling so believe me it’s appreciated.

    Greg

  • #8 / Apr 01, 2011 11:26pm

    Brett Gullan

    70 posts

    No worries, Greg. Glad you got it sorted. Cheers, B.

  • #9 / Apr 03, 2011 5:14pm

    Greg Salt

    3988 posts

    Hi fensterbaby,

    Glad that Brett was able to help you with this. Please open a related thread if you have further questions or problems.

    Cheers

    Greg

    @Brett, thank you very much for help out.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases