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.

one to many relationships for portfolio

September 15, 2010 4:26am

Subscribe [3]
  • #1 / Sep 15, 2010 4:26am

    R Gruyters

    14 posts

    I’m just wondering, is it possible to create a one to many relationships based on one custom field?

    For example, i have created a new field group named “portfolio” which includes the following custom fields:

    Company (text input)
    Description (textarea)
    Website (text input)
    Keywords (Tagger)
    Thumbnail (File)
    Images (File)

    For the portfolio page I have setup multiple categories (e.g. company brand, printing, websites, etc.)

    The idea is that my client can publish a new portfolio based on the category and I want to display related portfolio’s based on company custom field.

    Is this possible? Should I go this route? Do people have other suggestions?

    Hope someone can help me.

  • #2 / Sep 15, 2010 10:00am

    Boyink!

    5011 posts

    Yes:

    Setup a relationship field on the side of the many (projects).  Configure it to choose entries from clients.

    With each project you’ll choose the client that it’s for.

    Then when looping through clients use the reverse_related_entries loop to pull all projects for each client.

  • #3 / Sep 15, 2010 10:06am

    R Gruyters

    14 posts

    So I need to have two separate channels, one projects and one clients. (Am I correct?)

    Yes:

    Setup a relationship field on the side of the many (projects).  Configure it to choose entries from clients.

    With each project you’ll choose the client that it’s for.

    Then when looping through clients use the reverse_related_entries loop to pull all projects for each client.

  • #4 / Sep 15, 2010 12:56pm

    Boyink!

    5011 posts

    Yep-two channels.

  • #5 / Sep 15, 2010 2:34pm

    R Gruyters

    14 posts

    Ok, I have created two new channels, a “client” and a “portfolio”.
    Channel client has the following custom fields:
    - website [text input]
      (contains the customer URL)
    - description [textarea]
      (description about the client)

    Channel portfolio has the following custom fields:
    - company [relationship]
      (related to client channel)
    - description [textarea]
      (description of the portfolio)
    - keywords [Tagger module]
      (list of tags)
    - thumbnail [file]
    - images [file]

    Channel portfolio is also grouped to category group “portfolio”.

    When I try to use related_entries or reverse_related_entries it doesn’t display anything.

    Below you see the code part that I currently use to display the portfolio article:

    {exp:channel:entries channel="portfolio" disable="member_data|pagination" url_title="{last_segment_absolute}"}
                        <div class="article group">
                            <h3>{title}</h3>
    <p>{if pf_images != ""}<br />
                            <div class="pf-brand"><br />
                                {pf_images wrap="image"}<br />
                            </div><!-- !.pf-brand --><br />
    {/if}<br />
                            <div class="pf-detail group"><br />
                                <div class="pf-info"><br />
                                    {pf_description}<br />
                                </div><!-- //.pf-info --><br />
                                <div class="pf-related"><br />
                                    </p><h4>U vindt meer van deze klant in</h4>
    <p>                                <div class="nav"><br />
                                        <ul class="fancy"><br />
                                            {related_entries id="pf_company"}<br />
                                            {categories}<br />
                                            <li><span class="icon">»</span> <a href="http://{path=portfolio}">{category_name}</a></li><br />
                                            {/categories}<br />
                                            {/related_entries}<br />
                                        </ul><br />
                                    </div><!-- !.nav --><br />
                                </div><!-- !.pf-related --><br />
                            </div><!-- //.pf-detail.group --><br />
                        </div><!-- //.article --><br />
                        {/exp:channel:entries}

    Where the related_entries starts there should be (or at least trying to) displaying list of categories which the current company is also listed in.

    What am i doing wrong here.

  • #6 / Sep 20, 2010 4:47am

    R Gruyters

    14 posts

    I found a way, but don’t know if this is the right way.

    {exp:channel:entries channel="portfolio" disable="member_data|pagination" dynamic="no" url_title="{last_segment_absolute}"}
                        <div class="article group"> 
                            <h3>{title}</h3><p> <br />
    {if pf_images != ""}<br />
                            <div id="slider" class="pf-brand"> <br />
                                <div class="scroll"> <br />
                                    <div class="scrollContainer"> <br />
                                        {pf_images}<br />
                                        <div class="panel" id="{row_id}"> <br />
                                            {pf_image} <br />
                                        </div> <br />
                                        {/pf_images}<br />
                                    </div> <br />
                                </div> <br />
                                <ul class="nav slideNav"> <br />
                                    {pf_images}<br />
                                    <li><a href="#{row_id}">Tab{row_id}</a></li> <br />
                                    {/pf_images}<br />
                                </ul> <br />
                            </div><!-- //slider.pf-brand --> <br />
    {/if}<br />
                            <div class="pf-detail group"> <br />
                                <div class="pf-info"> <br />
                                    {pf_description}<br />
                                </div><!-- //.pf-info --> <br />
                                {related_entries id="pf_client"}<br />
                                {embed="portfolio/.related" rel_id='{entry_id}'}<br />
                                {/related_entries}<br />
                            </div><!-- //.pf-detail.group --> <br />
                        </div><!-- //.article --> <br />
                        {/exp:channel:entries}


    And here portfolio/.related template:

    <div class="pf-related"> 
                                    <h4>U vindt meer van deze klant in</h4><p> <br />
                                    <div class="nav"> <br />
                                        <ul class="fancy"> <br />
                                        {exp:channel:entries channel="client" entry_id="{embed:rel_id}"}<br />
                                            {reverse_related_entries}<br />
                                            {categories}<br />
                                            <li><span class="icon">»</span> <a href="http://{path=portfolio}">{category_name}</a></li> <br />
                                            {/categories}<br />
                                            {/reverse_related_entries}<br />
                                        {/exp:channel:entries}<br />
                                        </ul> <br />
                                    </div><!-- !.nav --> <br />
                                </div><!-- !.pf-related -->

  • #7 / Mar 07, 2012 9:32am

    Markroberson

    4 posts

    Well your sharing was quite useful and shared a lot of information with us, however, there are many other formulas i had seen on the google last days. Well, you information shared was highly useful to me.

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

ExpressionEngine News!

#eecms, #events, #releases