Another doozy - categories list and reverse_related_entries
Posted: 12 March 2008 02:16 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  266
Joined  07-24-2007

Let’s see if I can get this across…

I have a design portfolio website I’m building (for myself). It has this structure:

The Main weblog, which reverse relates to seperate weblogs with portfolio entries (one for each type, with the names: port_print, port_web, port_logos, etc). I have one Main entry for each type as well, one called Print (url titled “print”), one called Web, one called Logos, etc. A sort of many to one relationship.

Two of the Portfolio weblogs have a category group attached to them, because I want to display the data for those weblogs differently in the site/portfolio template and categories seemed like the best way. So, for instance, the port_print weblog has Print Categories attached to it (“business card” “letterhead” “postcards” etc). To denote each port_print entry from one another.

So a user clicks on “see the print portfolio” on my menu. It leads to the site/portfolio/print template, filled with data from the Main entry called “Print” (“print” being the url_title of the Main weblog entry I want to access with that link). In the instances of Main weblog entries for Web or Logos, etc, I am simply reverse-relating an iteration of thumbs and links to all the items in the port_web or port_logos weblogs. (Those links lead to a new template, site/details/url_title.)

But in the “site/portfolio/print” entry (which again is of the Main weblog), I want to generate a list of all things in the reverse-related print entry of the port_print weblog, separating out by category, trying to use this wiki method.

So, for the print page, I want to see the following on the site/portfolio:

Category 1 (ie Business Cards)
{reverse_related_entries link to “port_print” weblog field for that category}
-{title} for business A
-{title} for business B
{/reverse_related_entries}

Category 2 (ie Letterhead)
{reverse_related_entries link to “port_print” weblog field for that category}
-{title} for business X
-{title} for business Y
{/reverse_related_entries}


I can get it working, except there seems to be a limit with the use of the {exp:weblog:entries} with {reverse_related_entries}. I can’t limit the reverse relationship to that category only. This is as close as I can get (I’ll leave the code alone for a spell, I have to do a few other things anyway.) There are three entries in my port_print weblog right now. All three show up in both categories that have entries attached. No idea why it’s also duplicating again, putting in a </div> tag and putting the duplicate outside my nice formatting. smile

The code that produces this (irrelevant code in another if snipped out):
{exp:weblog:entries weblog=“main”}

—snip—

{if:elseif url_title == "print"}

{exp
:weblog:categories weblog="port_print" show_empty="no"}
{category_name}
<br />

{exp:weblog:entries weblog="port_print" orderby="date" category="{category_id}" sort="asc" limit="50" dynamic="off" }

{reverse_related_entries id
="pagelink" }
<a href="{title_permalink="weblog/comments"}">{pagetitle}</a><br />
{/reverse_related_entries}

{
/exp:weblog:entries}
{
/exp:weblog:categories}

{
/if}

{
/exp:weblog:entries}

Any ideas? Impossible? Is there a better way to do this to begin with? I’m willing to do a (limited) amount of restructuring, though the rest of the site works so well right now…I’d hate to change THAT much!

Edit: Another issue is that of course, I tried to use dynamic=“off” in the weblog:entries inside the exp:weblog:categories tag, and that means it shows up on other weblog entries in the same template. Duh. But otherwise, you get just ONE category (not even both of them) to show up, with no related entries listed underneath…

Profile
 
 
Posted: 07 July 2008 02:54 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

I’m trying to do almost this exact same thing, and it’s not working for me, either.

I use a fairly common Category Archive Loop to loop through categories and spit out the entries that belong to that category for each category. I’m running into a brick wall trying to do that with reverse related entries, though, which led me to this post.

I have a main entry in “portfolio” weblog.

I have another weblog called “portfolio_images” that has a relationship field relating the image entry here to a “portfolio” entry. There are 4 possible image categories.

On a portfolio entry page, I want to output all the portfolio_images that relate to this entry by category. Works fine if you’re doing this without reverse related entries, like this (simplified):

{exp:weblog:category_archive weblog="portfolio_images" style="linear"}
{categories}
  {exp
:weblog:entries weblog="portfolio_images" dynamic="off" category="{category_id}"}
   {if count
== '1'}
    
<h2>{category_name}</h2>
   
{/if}
    {title}
<br />
  
{/exp:weblog:entries}
{
/categories}
{
/exp:weblog:category_archive}

But if my portfolio_image entries are reverse_related, and I’m trying to get similar output from inside my “portfolio” entries tag…well, what a mess. Seems like there might be a certain number of embeds one would have to do to get this to work.

Has anyone gotten a categories list and reverse_related_entries to work?

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 08 July 2008 08:25 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

I ended up doing this by writing an Extension called “Simple Relation”, that only stores an entry_id. I avoided reverse related entries altogether!

Simple Relation (main forum thread)
Simple Relation (Download)

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 08 July 2008 09:20 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  266
Joined  07-24-2007

Wow, though I did actually just use a workaround for my problem which started this thread (I think I ended up using different templates for each type of Main weblog and went from there), this could come in handy.

I wish I were geek enough to write plugins. But the contributions of people like you are what make people like me able to keep making better sites with EE. Thanks bunches!

Profile
 
 
Posted: 08 July 2008 12:52 PM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006
LynneL - 08 July 2008 09:20 AM

I wish I were geek enough to write plugins. But the contributions of people like you are what make people like me able to keep making better sites with EE. Thanks bunches!

I wish I were geek enough, too. I’m just a hack with a degree in Fine Art wink

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 08 July 2008 01:07 PM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  266
Joined  07-24-2007

Hey, I don’t even got one of those! Just a BA in English. wink

What sort of fine art? My minor was in studio art, I still do the occasional painting here and there.

Profile
 
 
Posted: 08 July 2008 01:19 PM   [ Ignore ]   [ # 6 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

Ha, I have a BFA in Oil Painting. I know who people like Euan Uglow, Balthus, and Chuck Close are. grin

I was pretty close to double majoring in English, too, but four and a half years of school is enough. I still read a lot gulp

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 08 July 2008 01:30 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  266
Joined  07-24-2007

Poetry, myself. Thought I would be a fiction writer but it turns out that I have more of an attention span appropriate for poetry. smile

Profile
 
 
   
 
 
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 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120486 Total Logged-in Users: 54
Total Topics: 126559 Total Anonymous Users: 20
Total Replies: 665414 Total Guests: 279
Total Posts: 791973    
Members ( View Memberlist )