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.

Sharing status with relationships?

July 11, 2007 7:33pm

Subscribe [2]
  • #1 / Jul 11, 2007 7:33pm

    kellysims

    123 posts

    I have an odd one here, at least to me. 😊

    I run a chamber of commerce site, whose main purpose is to showcase their member businesses. I had originally setup the system two years ago using a weblog for the companies and many custom fields. These fields included member reps of these companies. Recently though, they wanted to be able to add in multiple reps for each company. At first, I started adding in all new custom fields, but this got way out of hand, and the publish page was a mess.

    So I ended up seperating the member reps into their own weblog, and now pull them into a template using realtionship fields to the list of company weblogs. All well and good, I thought.

    But now, I realize this adds a small problem. If a company is then set to a closed status, the member reps will still show up.

    Is there a way to run a template showing all member rep weblog entries using the status of the company weblog?

    This sounds like a mes even as I type this. If this were anything other than EE, I’d not even bother.

  • #2 / Jul 11, 2007 7:42pm

    Stephen Slater

    366 posts

    I think I was following you until this portion…

    But now, I realize this adds a small problem. If a company is then set to a closed status, the member reps will still show up.

    Where are the member reps still showing up?  on the site or in the control panel?

  • #3 / Jul 11, 2007 7:55pm

    kellysims

    123 posts

    Ooops, should have included URL’s.

    I have a page that pulls all member reps from their weblog, status open. The problem is that when their respective company is set to closed, they still show up in the page listing all reps.

    Is it possible to somehow have the status of the company entries effect the member rep entries (2 sep. weblogs)?

    http://industrialcouncil.org/members/representatives/  main rep page list.

    http://industrialcouncil.org/membership/Directory  main directory page then to each company

  • #4 / Jul 11, 2007 11:45pm

    Stephen Slater

    366 posts

    Would it be possible for you to paste the code you are using for each?  Just the code that pulls in the weblog data.  Both direct and reverse.  I think there may be a way to do this, but I’m not sure.  I’d like to see the code to test against my thinking…

  • #5 / Jul 12, 2007 1:49pm

    kellysims

    123 posts

    Here’s the code I’m using to list all the member reps:

    {exp:weblog:entries weblog="member_reps" status="open" orderby="member_rep_lastname" sort="asc"}
    <dl class="memberboxes">
    <dt><h3 class="subarticle">Member Representative for {related_entries id="member_rep_company"}{title}{/related_entries}</h3></dt>
    
    <dd>{exp:search_hilite}
    {if member_rep_photo}{member_rep_photo}{/if}
    <span class="company"><a href="/members/representative/{url_title}">{title}</a>{if member_rep_title}, {member_rep_title}{/if}</span>
    {exp:ptobr}{if member_rep_address}<span class="address">{member_rep_address}
    </span>{/if}{/exp:ptobr}
    {if member_rep_phone}<span class="phone">Phone: {member_rep_phone}
    {/if}
    {exp:ptobr}{if member_rep_fax != ""}Fax: {member_rep_fax}{/if}</span>{/exp:ptobr}
    {/exp:search_hilite}
    {exp:ptobr}{if member_rep_email}Email: {member_rep_email}
    {/if}{/exp:ptobr}
    {exp:ptobr}{if member_rep_website}Website: {member_rep_website}{/if}{/exp:ptobr}
    </dd>
    </dl>
    
    {/exp:weblog:entries}

    And the Directory weblog list:

    {exp:weblog:entries weblog="Directory" status="open|Highlighted" sort="asc" orderby="title" start_on="1958-09-05 12:00 PM" limit="9999"}
    
    <dl id="memberboxes">
    <dt>{if category < 2}<h3 class="subarticle">{categories backspace="2"}{category_name} / {/categories}</h3>{/if}</dt>
    <dd><span class="membersince">Member Since: {entry_date format="%m/%d/%Y "}</span></dd>
    <dd class="logo">{CompanyLogo}</dd>
    {exp:search_hilite}<dd>{exp:search_hilite}<span class="company">{Company}</span>
    {if Address_Preference == "Yes" OR Address_Preference == ""}<span class="address">{Street}
    {/if}
    {if City != ""}{City} {if:else}Commerce{/if} {if State != ""}{State} {if:else}CA {/if}{if Zip != ""}{Zip} {if:else}90040{/if}</span>
    <span class="phone">{Phone} {if Fax != ""}Fax: {Fax}{/if}</span>
    <span class="contact">{ContactName}{if ContactTitle != ""}, {ContactTitle}{/if}</span>{/exp:search_hilite}
    {if show_email == "Yes"}{Email}
    {/if}
    {Website}
    </dd>
    
    </dl>
    {/exp:weblog:entries}

    I’ve tried to remove some of the extraneous code here. Thanks for the help so far!

  • #6 / Jul 12, 2007 2:19pm

    Stephen Slater

    366 posts

    Okay, here is my thinking and I am not sure if it’s a solution (sorry if it isn’t).  Relationships make my head spin a little bit…

    Could you use a reverse relationship to display the companies?  I’m thinking if you use a reverse relationship, it would adopt the status of it’s children.  I could have this backwards, but this will get you thinking in this direction…  Use relationships to show the children and reverse relationships to show the parents.

    http://expressionengine.com/docs/modules/weblog/reverse_related_entries.html


    Again, this makes my brain hurt, so if I’m way off, you’ll have to excuse me.  Without actually testing it, I cannot guarantee it will work.

  • #7 / Jul 12, 2007 11:41pm

    kellysims

    123 posts

    I’m still working on this. I spent a good chunk of the day, relationshipping (I make ‘um up as I go here). I think I may have started wrong with this one, and may be why I’m having trouble. I’m looking at redoing things so that my company weblog has a multi-relationship field for member reps. I think this may work better, and I’ll post back here when I get a chance.

    You’re right though, these relationships bring on headaches rather quickly.

  • #8 / Jul 13, 2007 2:47pm

    kellysims

    123 posts

    So far I have this, and it’s working:

    {exp:weblog:entries weblog="Directory" status="open|Highlighted" sort="asc" orderby="company_member_reps" limit="9999"}
    
    {related_entries id="company_member_reps"}
    <dl class="memberboxes">
    <dt><h3 class="subarticle"><a href="/members/representative/{url_title}">{title}</a></h3></dt>
    
    <dd>
    {if member_rep_title} <i>{member_rep_title}</i>{/if}<br>{/related_entries}
    {if company_member_reps != ""}<b><a href="/memberships/members/{url_title}">{title}</a></b>
    {/if}
    {related_entries id="company_member_reps"}
    {if member_rep_photo}{member_rep_photo}{/if}
    {if member_rep_address}{exp:ptobr}<span class="address">{member_rep_address}
    </span>{/exp:ptobr}{/if}
    {if member_rep_phone}{exp:ptobr}Phone: {member_rep_phone}
    {/exp:ptobr}{/if}
    {if member_rep_fax}{exp:ptobr}Fax: {member_rep_fax}
    {/exp:ptobr}{/if}
    {if member_rep_email}{exp:ptobr}Email: {member_rep_email}
    {/exp:ptobr}{/if}
    {if member_rep_website}{exp:ptobr}Website: {member_rep_website}
    {/exp:ptobr}{/if}
    </dd>
    </dl>
    {/related_entries}
    {/exp:weblog:entries}

    But now I have to figure out how to sort the related entries, alphabetically. I ended up adding a multi-relationship field in company weblog fields that relates to member rpes entries, instead of the other way around. The companies should have been parent to begin with, my bad.

  • #9 / Jul 16, 2007 2:18pm

    kellysims

    123 posts

    This seems to be working best for me, but I am still wanting to output a page sorted alphabetically for my member_reps weblog. Since I can’t sort using a relationship field, is there anyone good with sql queries that could sort this?

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

ExpressionEngine News!

#eecms, #events, #releases