Related Articles tag not returning related articles
Posted: 01 July 2009 08:28 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  221
Joined  06-28-2009

(Slavishly) following the instructions and sample code in a tutorial, I set up the following code intended to return up to three related articles for each posted article. However, when I substituted the expression engines tags for the html code originally provided, the rendering comes back with “Related Articles” blank.

I suspect that it has something to do with where the “close” tag is being placed—if I move it in front of the </div> expression, it comes back empty. If I move it behind the </div> expression, it comes back with the raw code for the title, author, and article_excerpt fields where the text for those entries should be.  But neither approach will return the actual article excerpts (even though it worked famously when I had sample text in the template instead of the expression engine tags).  Here is the code for that section (BTW, categories are “on” and I intentionally made sure that there were at least two other articles assigned to this category—so there should be content to come back, unless there is some other step I’ve missed.)

<div id="related-articles">
                <
h3>Related Articles</h3>
                 
                
{exp:weblog:entries weblog="news_articles" limit="3" related_categories_mode="on" custom_fields="on" status="Open|Top Story|Featured Top Story"}
                
                {if no_results}
                
<p>There are no related articles</p>
                
{/if}
                    
                
<div id="{switch="lcol|mcol|rcol"}">
                    <
h4>{title}</h4>
                    <
h5><span class="by">By</span> {author}</h5>
                    
{article_excerpt}
                    
                               
<p><a href="{title_permalink=" class="read_story">Read Story</a></p>
                        
{/exp:weblog:entries}
                
        

    


</div><!-- END #related-articles -->
Profile
 
 
Posted: 01 July 2009 11:57 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRank
Total Posts:  5233
Joined  03-22-2004

Hoopsgal,

There is no parameter custom_fields=“on”. If you want to turn off stuff use the disable parameter

Where does this code live? On a single entry page?

http://www.eample.com/index.php/template-group/comments/entry-title

<div id="related-articles">
                <
h3>Related Articles</h3>
                 
                
{exp:weblog:entries weblog="news_articles" limit="3" related_categories_mode="on"  status="Open|Top Story|Featured Top Story"  disable="pagination|categories|member_data|trackbacks"}
                
                {if no_results}
                
<p>There are no related articles</p>
                
{/if}
                    
                
<div id="{switch="lcol|mcol|rcol"}">
                    <
h4>{title}</h4>
                    <
h5><span class="by">By</span> {author}</h5>
                    
{article_excerpt}
                    
                               
<p><a href="{title_permalink=" class="read_story">Read Story</a></p>
                        
{/exp:weblog:entries}
                
        

    


</div><!-- END #related-articles -->
 Signature 
Profile
 
 
Posted: 03 July 2009 10:27 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  221
Joined  06-28-2009

It lives on a template called view.php. That is the page where, if you click read more on any story on any page in the site, you get to see and comment on the full story.
So basically, the page has one main story (which can be pulled out of what will be hundreds of stories, plus the comment form, plus a read out of stories related to the main story by either category or author.

If I’m getting the terminology right, that wouldn’t be a single entry page, because it isn’t just typed text that stays the same constantly, but rather text pulled in from from wherever the user has clicked on the Read More link.

Also, you’ve asked for a link, but my site is off-line until I get these problems hammered out. Can you tell me, as a newbie, what kind of link I would be giving you if the site is off-line. Or if there is some other way to let you view the problem (without having the whole world viewing it at the same time!)

Thanks

Profile
 
 
Posted: 03 July 2009 10:43 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  221
Joined  06-28-2009

I found the answer to at least a piece of this problem: I had foolishly neglected to close the {exp:weblog:entries”} tag. Having fixed that, I at least get stories appearing, though how they are related (other than that they are all on the site), initially eluded me.

Though the tutorial would have you believe that this tag is going to return only stories assigned to the same category or by the same author, it looks like the expression is returning all stories related to the same PARENT category, instead of to the child category. Since the parent category is “News” that’s way overbroad—75% of the stories on the site will be news articles.

What I need it to do is return only stories related to the same CHILD category—e.g., not just any News Article, but those on News-WNBA or, if it’s a college story, News-NCAA. Eventually, even those categories will be overbroad, and we would just want stories on a particular team, e.g., the Detroit Shock or the Connecticut Huskies, or perhaps even by player. 

Can you suggest how to fix this so that ONLY related stories (by child category if there is a child category for that category and/or author) get returned, and if there are none, we get the “There are no related articles for this story” line instead of an assortment of random stories?

Also, while on the topic of categories, how refined can we make it? Can you set up a child of a child, for example, so that a Story be categorized to News-WNBA-Eastern Conference-Detroit Shock?

Also, how many categories can the same story have? Can you set it up so that the same story can belong to more than one category—e.g., a team category and a player category —so that if someone wants to look at stories related to the Detroit Shock, they would get that, but so would someone wanting to look up only stories about Karl Malone’s daughter Cheryl Ford? If so, how would you implement something like that?

I would think it might come up often—e.g., someone wanting to categorize items to Business generally, but also wanting to make them readily available to someone using the site to research a particular company or stock.

Thanks.

Profile
 
 
Posted: 06 July 2009 01:24 AM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRankRankRank
Total Posts:  5233
Joined  03-22-2004

Hoopsgal,

Though the tutorial would have you believe that this tag is going to return only stories assigned to the same category or by the same author, it looks like the expression is returning all stories related to the same PARENT category, instead of to the child category. Since the parent category is “News” that’s way overbroad—75% of the stories on the site will be news articles.

By default when you select a child category int he Publish page it also selects the parent. You can disable this behaviour by switching Auto-Assign Category Parents to No

CP Home ›  Admin ›  Section Administration ›  Global Section Preferences

I believe that your articles have been assigned to the parent and the child at the time of publishing which explains the behaviour you describe.

Also, while on the topic of categories, how refined can we make it? Can you set up a child of a child, for example, so that a Story be categorized to News-WNBA-Eastern Conference-Detroit Shock?

Yes you can. Did you try adding subcategories?

EE Docs : Category Management

Also, how many categories can the same story have? Can you set it up so that the same story can belong to more than one category—e.g., a team category and a player category —so that if someone wants to look at stories related to the Detroit Shock, they would get that, but so would someone wanting to look up only stories about Karl Malone’s daughter Cheryl Ford? If so, how would you implement something like that?

You can assign multiple category groups to weblogs and multi select categories when creating an entry.

I would suggest reading over the category sections of the documentation and trying out different scenarios within your CP to become more familiar with it.The Wiki also has some more tips outside of the documentation.

 Signature 
Profile
 
 
Posted: 06 July 2009 03:14 PM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  221
Joined  06-28-2009

By default when you select a child category int the Publish page it also selects the parent. You can disable this behaviour by switching Auto-Assign Category Parents to No

CP Home ›  Admin ›  Section Administration ›  Global Section Preferences

I believe that your articles have been assigned to the parent and the child at the time of publishing which explains the behaviour you describe.


Thanks, John

The problem with this approach is that it is a “Global” Section Preference.” There are some functions for which I DO want Expression Engines to be able to pull up the whole Parent, Child, Grand-Child, Great-Grandchild structure (as for example, if someone is trying to do a category search, starts with league, goes to team, then goes to player on that roster.”  It’s just that Related Articles is not one of them.

Also, is the only way to set multiple categories to create two (or more) custom category groups for the same weblog? Because it would be a lot easier if expression engine simply let you choose more than one option off the same drop-down list of categories, rather than repeating that drop-down list in multiple category groups (which seems like it might screw up the parent-child-etc. structure.

For example, let’s say I try to accomplish what I think you’re describing by creating multiple custom category groups—one for league, one for team, one for players, etc. Wouldn’t that prevent us, down the line, from having someone interested in articles about the Shock, and then have them see as well as articles about the Shock generally, articles about particular players on the Shock roster. Because instead of being categorized as a player in the single custom group that would have the Shock’s roster as a grand-child of the WNBA category group (i.e., WNBA-Detroit Shock-Cheryl Ford), you’ve instead got the article categorized in three separate category groups—WNBA for the league category group, Shock for the team group, and Ford for the player group?

I suppose that would have it’s advantages if, for example, next year, Ford migrates to the Atlanta Dream. So she’s no longer with the Shock and since the article was published a year earlier, and dealt with the Shock, you wouldn’t want to re=categorize it to the Dream and lose the link to the team that the article was originally about. So, having a separate category for players, by name, would be useful in that instance. But eventually, you’d have a massive proliferation of category fields on your entry form. Player by year, etc.

Seems like this is something that ought to be solved by how you structure a particular template and tell it to query the database, rather than by setting a global template for all uses of the category group, but I could (easily) be missing something as I’m new to all this.

Thanks.

Profile
 
 
Posted: 07 July 2009 02:00 AM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRank
Total Posts:  5233
Joined  03-22-2004

Hoopsgal,

Because it would be a lot easier if expression engine simply let you choose more than one option off the same drop-down list of categories

CP Home ›  Admin ›  Section Administration ›  Section Management ›  Edit Group Preferences

The category group selection is a multi select box if I am not mistaken so you can CTRL click a number of them

I am gonna move this thread to the ‘How to’ forum as it is more method than an issue you are having.

The best advice I can give is to not be tied down to one method of ‘categorising’ your information. While there are many add-ons that can solve a lot of your category issues.

I find the best results and room for expansion always come form a combination of weblogs, categories, entries and related entries.

I use the Playa extension quite a bit for relating entries to other weblog entries


Work your way through all different methods and decide which one it ticks all your boxes in terms of what it can offer as an end result. There is no one method on how to reach an end goal in EE which is the beauty of it hence why this post is not a yes or no answer.

Hopefully there are a few leads in my answer that you will find helpful.

Any technical issues along the way let us know and we will be here.

 Signature 
Profile
 
 
Posted: 07 July 2009 08:16 AM   [ Ignore ]   [ # 7 ]  
Lab Assistant
RankRank
Total Posts:  221
Joined  06-28-2009

“A few leads”? You’re kidding. You’ve given me a lot to consider and follow-up on. Thanks.

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: 120603 Total Logged-in Users: 61
Total Topics: 126642 Total Anonymous Users: 40
Total Replies: 665701 Total Guests: 399
Total Posts: 792343    
Members ( View Memberlist )
Newest Members:  bell143paololukDarleneChadbourneRashadSargIvar89HonschowmtRetliffherzigerjudith