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.

Behind the Curtain Part IV

August 20, 2007 12:16pm

Subscribe [13]
  • #1 / Aug 20, 2007 12:16pm

    Derek Jones

    7561 posts

    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…

  • #2 / Aug 20, 2007 1:59pm

    ms

    274 posts

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

    Thanks, Derek!

  • #3 / Aug 20, 2007 2:49pm

    e-man

    1816 posts

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

  • #4 / Aug 21, 2007 1:42am

    stinhambo

    1268 posts

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

  • #5 / Aug 21, 2007 5:02am

    sigork

    155 posts

    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.

  • #6 / Aug 21, 2007 9:42am

    Derek Jones

    7561 posts

    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.

  • #7 / Aug 21, 2007 9:52am

    sigork

    155 posts

    is collaboration and working with articles

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

  • #8 / Aug 21, 2007 1:05pm

    mattbrighton

    50 posts

    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?

  • #9 / Aug 21, 2007 1:21pm

    Derek Jones

    7561 posts

    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.

  • #10 / Aug 21, 2007 1:28pm

    mattbrighton

    50 posts

    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.

  • #11 / Aug 21, 2007 5:13pm

    jschutt

    452 posts

    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?

  • #12 / Aug 21, 2007 5:22pm

    Derek Jones

    7561 posts

    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.

  • #13 / Aug 21, 2007 6:04pm

    jschutt

    452 posts

    That makes sense!  Thanks for the explanation.

  • #14 / Aug 22, 2007 9:54am

    jschutt

    452 posts

    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!

  • #15 / Aug 22, 2007 10:11am

    Derek Jones

    7561 posts

    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.

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

ExpressionEngine News!

#eecms, #events, #releases