1 of 2
1
Behind the Curtain Part IV
Posted: 20 August 2007 09:16 AM   [ Ignore ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15743
Joined  06-03-2002

Part IV in the Behind the Curtain series was delayed for longer than I anticipated.  So without further ado, let’s dive right in, shall we?  The topic of Part IV is relationships.  Relationships can be a very powerful tool when designing the data structure of your site.  For some, relationships are clouded in mystery, and not having seen them used in a practical sense, they either avoid relationships, or use them poorly.  So we’ll look at a real world example that I used when redesigning our site, and this will perhaps help you identify with this feature of ExpressionEngine.

Continue reading…

 Signature 
Profile
MSG
 
 
Posted: 20 August 2007 10:59 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  768
Joined  03-16-2002

Hey ... BtC is back! And on relationships…

Thanks, Derek!

Profile
 
 
Posted: 20 August 2007 11:49 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1441
Joined  09-16-2004

Took me a few seconds to see what those {if count…} statements were doing smile
Neat!

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 20 August 2007 10:42 PM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1576
Joined  01-05-2007

Wow that’s awesome. I wonder if I could of used this method for any previous sites…

 Signature 

 
Steven Hambleton | ExpressionEngine Development for Web & Graphic Design Agencies

Profile
 
 
Posted: 21 August 2007 02:02 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
RankRankRank
Total Posts:  978
Joined  06-13-2005

I think the information on http://expressionengine.com/overview/features/ could be taken from a Wiki.

I think the Wiki can be more suitable for the above purpose than a blog (“Features - Entries”).

Can that relation be established between a Wiki and the ‘Features - Categories’ blog?

Thanks.

 Signature 

tulks.com

Profile
 
 
Posted: 21 August 2007 06:42 AM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15743
Joined  06-03-2002

I disagree, sigork.  The entire purpose of a Wiki is collaboration and working with articles (i.e. one large field as opposed to any number of custom fields).  The individual features here are not subject to interpretation nor authored by many people (nor do they regularly change).  Custom fields and a weblog are much more appropriate, at least for us.  The terminology might be stumbling block here: these aren’t ‘blogs’, they are data containers.

The short answer, though, is no, no such relationship could be made, at least not without some custom development and an artificial method to create the associations.  Sounds like a lot of work when this feature is ready to go out of the box and works perfectly.  And having some of the content for this page controlled in the Publish page, and some in a front-end Wiki is rather jarring.  You really can’t get much more straight forward than what I’ve done here; I’m afraid I’m not seeing the benefit of having any of this in a wiki.

 Signature 
Profile
MSG
 
 
Posted: 21 August 2007 06:52 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
RankRankRank
Total Posts:  978
Joined  06-13-2005
Derek Jones - 21 August 2007 06:42 AM

is collaboration and working with articles

Yes, you are completely right, I forgot about that :(

 Signature 

tulks.com

Profile
 
 
Posted: 21 August 2007 10:05 AM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  144
Joined  07-21-2006

Loving this series and finding it very valuable.

Fantastic illustration of use of relationships, thanks. Really helpful in regard to implementing this practically.

Could you pull in member data into this through a member custom field, or would this require the use of the query module in a particular weblog?

 Signature 

// matthanson.net
// twitter

Profile
 
 
Posted: 21 August 2007 10:21 AM   [ Ignore ]   [ # 8 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15743
Joined  06-03-2002
mattbrighton - 21 August 2007 10:05 AM

Could you pull in member data into this through a member custom field, or would this require the use of the query module in a particular weblog?

Yes, just like the weblog entries tag, custom member fields are available within the {reverse_related_entries} tag pair.

 Signature 
Profile
MSG
 
 
Posted: 21 August 2007 10:28 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  144
Joined  07-21-2006
Derek Jones - 21 August 2007 10:21 AM

Yes, just like the weblog entries tag, custom member fields are available within the {reverse_related_entries} tag pair.

Fantastic. This will definitely come in useful.

 Signature 

// matthanson.net
// twitter

Profile
 
 
Posted: 21 August 2007 02:13 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  366
Joined  09-20-2006

I am one who would fall into the “cloudy” category regarding relationships.  Could you please explain why you used the {reverse_related_entries} tag instead of the {related_entries} tag?

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 21 August 2007 02:22 PM   [ Ignore ]   [ # 11 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15743
Joined  06-03-2002
jschutt - 21 August 2007 02:13 PM

I am one who would fall into the “cloudy” category regarding relationships.  Could you please explain why you used the {reverse_related_entries} tag instead of the {related_entries} tag?

Sure thing, jshcutt.

It all boils down to how the information is presented and displayed.  The decision was basically made for me by the design.  Related entries show one entry per custom field.  So to get the presentation that I have here with related entries, I would need one custom field per every possible feature, and to publish a new feature, I’d have to publish the new entry in “Features Entries” and go to the parent “Features Category” entry, and swim through a list of relationship custom fields for the next empty one, and select my newly published feature entry.  On the template side of things, I’d have to have a {related_entries id=“foo”} tag for every custom field.

Reverse relationships allow me to make my “Categories” the actual children, and the individual features the parent.  This lets me have only one relationship field, and only have to publish or modify one entry to add and make changes.

If that break down doesn’t help you (it’s late afternoon and very hot, so my explanation is probably not super) try thinking of it this way:  A parent can only show one child per custom field, but a child can without any custom fields at all show all of its parents.

 Signature 
Profile
MSG
 
 
Posted: 21 August 2007 03:04 PM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  366
Joined  09-20-2006

That makes sense!  Thanks for the explanation.

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 22 August 2007 06:54 AM   [ Ignore ]   [ # 13 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  366
Joined  09-20-2006

Derek,

Can you see if this makes sense? 

I need to make an MP3 audio archive that consists of multiple mp3’s from multiple speakers at multiple events.  (sounds like fun, huh?)

After reading this Behind the Curtain, a light bulb went on.  I created a weblog to hold the MP3 files that also has a category group with all of the possible events.  That should take care of pulling up the files attributed to any particular event.

Should I now create a “Speaker” weblog to hold all of the speakers?  Then I could relate entries from the MP3 weblog to the particular speaker in the “Speaker” weblog and use the {reverse_related_entries} to pull up all of the MP3’s attributed to any particular speaker.

In the moments that this is clear in my mind, it seems to be very similar to what you did with the features section of the EE site.

PS - Feel free to move this into a new location in the forums if necessary!

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 22 August 2007 07:11 AM   [ Ignore ]   [ # 14 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15743
Joined  06-03-2002

You are indeed correct; it’s a perfect parallel—so long as there is only one speaker per MP3.  If there’s more than one speaker per MP3, then your MP3 weblog will need to have relationship fields (all pointing to the “Speaker” weblog) equal to the number of the highest possible number of speakers that will be attributed to an MP3 file.

 Signature 
Profile
MSG
 
 
Posted: 22 August 2007 07:36 AM   [ Ignore ]   [ # 15 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  366
Joined  09-20-2006

Sounds great!  Thanks so much for the direction.

I am going to work on this for awhile and I will let you know how it goes.

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 22 August 2007 04:25 PM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  366
Joined  09-20-2006

Derek,

On your features page, how would you have accomplished grouping some of the different features within your categories?

Maybe this will be clearer - I have some speakers who speak at multiple events.  I have it already set up to create a relationship from the mp3’s to the speaker.  I also have it set up to display the speaker, a picture, a bio, as well as any of the mp3’s that are related to him.  My question is this - Is there anyway to group mp3’s from each event for a speaker that has multiple events to his credit?

I have tried using the following:

{exp:weblog:entries weblog="speaker_info" limit="15" sort="desc"}
    
<div class="descriptionlist">
      <
div class="inlineImage left">{speaker_image}</div>
      <
h3>{title}</h3>
      
{if speaker_bio == ""} <p><i>No Bio Info Available</i></p>{/if}<p>{speaker_bio}</p>


{exp:weblog:category_heading}
<h1>{category_name}</h1>
{/exp:weblog:category_heading}

<ul>
{reverse_related_entries sort="desc" orderby="date" sort="asc"}
<li><a href="{mp3_url}" target="_blank">{title} {if subtitle !=""}&mdash;{/if} {subtitle}</a></li>
{/reverse_related_entries}
</ul>

<
hr class="clearboth" />  
  </
div>

{/exp:weblog:entries}

But since the {exp:weblog:category_heading} is not inside of the {reverse_related_entries}, I get nothing.  If I put it inside of the {exp:weblog:category_heading}, I get nothing either mad

Any help would be appreciated!

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 22 August 2007 04:29 PM   [ Ignore ]   [ # 17 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15743
Joined  06-03-2002

That tag’s not meant to be nested (and is also intended only for category pages).  What you are looking for is the category variable pair of the weblog entries tag (and by extension the reverse related entries tag pair).

 Signature 
Profile
MSG
 
 
Posted: 22 August 2007 04:32 PM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  366
Joined  09-20-2006

I had tried that.  I think…

But when I placed that inside of the {reverse_related_entries} tag, it loops through each of the mp3 entries.  What I am trying to accomplish is one header that lists the event category for any applicable mp3’s.

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64547 Total Logged-in Users: 27
Total Topics: 81141 Total Anonymous Users: 22
Total Replies: 436539 Total Guests: 182
Total Posts: 517680    
Members ( View Memberlist )