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.

Using search parameter to filter results

October 01, 2011 1:49pm

Subscribe [2]
  • #1 / Oct 01, 2011 1:49pm

    JPDesignDev

    20 posts

    I am not sure that this is the best approach to my problem, but I believe this should work.

    I have a Product Brand page that links to a Product Line page.

    The Product Line channel contains a Relationship Custom Field called product_brand which is related to the Product Brand channel.

    Here is the code block in my Product Line template.
    The following code has been simplified for readability (remove HTML classes, IDs, etc.):

    {exp:channel:entries channel="product_line" search:product_brand="Brand Name"} 
    
    <!-- I know this will not be Brand Name. It should contain the string from the relationship drowdown 
    right? Placing not IS_EMPTY returns all entries under Product Line regardless of their relationship 
    or lack of a relationship -->
                      
                <div>
                 <a href="#">_                 {product_line_image}_                </a>
                    
                    <h3><a href="#">{title}</a></h3>
    <p>                <br />
                    {product_line_description}<br />
                    <br />
                    <a href="#">Learn More</a><br />
                    <br />
                </div><br />
                            <br />
    {/exp:channel:entries}

    Can I not reliably retrieve the value of a relationship custom field?

    Please let me know if this is confusing.

  • #2 / Oct 01, 2011 1:57pm

    JPDesignDev

    20 posts

    Seems that I am blind. I found the following line in the documentation:

    Note: Only fields of the type “Text Input”, “Textarea”, and “Drop-down Lists” are searched with this parameter.

    Does anyone have a suggestion for what I am trying to achieve.

  • #3 / Oct 02, 2011 1:33pm

    Kevin Smith

    4784 posts

    Hi JPDesignDev,

    To be honest, I might be a bit confused about what you’re trying to achieve. Let me see if I understand: It looks like you want to return all entries in the Product Line channel that are related to a particular brand (entry) in the Product Brand channel, correct?

    If so, it sounds like you’re looking for Reverse Related Entries. This allows you to display all the Product Line entries that have selected a particular brand (entry) in the Product Brand channel as its related field.

    Does this make sense?

  • #4 / Oct 03, 2011 11:51am

    JPDesignDev

    20 posts

    Hi JPDesignDev,

    To be honest, I might be a bit confused about what you’re trying to achieve. Let me see if I understand: It looks like you want to return all entries in the Product Line channel that are related to a particular brand (entry) in the Product Brand channel, correct?

    If so, it sounds like you’re looking for Reverse Related Entries. This allows you to display all the Product Line entries that have selected a particular brand (entry) in the Product Brand channel as its related field.

    Does this make sense?

    Yes. Upon click a particular Product Brand, all Product Line’s relating to that Product Brand will be shown. Your explanation of Reverse Related Entires sounds like what I thought it was.

    The documentation describes it like this:
    A Reverse Relationship would be the child entries displaying all of the parent entries that have created a relationship with it.

    I don’t necessarily need to display any information about the Product Brand (entries). I only need to display info about the Product Lines (entries) that are “children” of a particular brand, so how would this be achieved. BTW, I know the steps to creating a relationship in the backend.

    Thank you for your help.

  • #5 / Oct 03, 2011 5:21pm

    Kevin Smith

    4784 posts

    The terminology is a little confusing here. Even though in your mind the product lines are children of their brand, when you’re using the relationship field to select a brand in each Product Line entry, the Product Line entry is the “parent” and the selected brand is the “child” (to be consistent with the User Guide’s use of terminology). So it seems backwards, which makes it a little difficult to understand with the setup you’re going for.

    If it were me, I probably wouldn’t set it up like this. Instead, I would make each brand a category (you can even have custom fields for categories), categorize the Product Line entries, and display all the Product Line entries of a particular category (brand) on the front-end of the site. It’s a bit easier to conceptualize.

    Does that make sense?

  • #6 / Oct 03, 2011 7:09pm

    JPDesignDev

    20 posts

    Thank you for this clarification. I have something that is working for me now.

    Brand Channel

    Product Line Channel (Brand Channel relationship)

    Products Channel (Product Line Channel relationship)

    I started out using categories, but I lost faith in the fact that I cannot force my client (via required field) to pick a category.

    I would say that this issue has been resolved, I guess.

  • #7 / Oct 04, 2011 10:27pm

    Kevin Smith

    4784 posts

    Glad you were able to find a working solution, JPDesignDev. Let us know if there’s anything we can do to help again in the future.

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

ExpressionEngine News!

#eecms, #events, #releases