Trying to filter weblog content by category using user category assignments
Posted: 27 January 2010 09:47 AM   [ Ignore ]
Member
Avatar
RankRankRank
Total Posts:  106
Joined  2006-12-12

I know this should work but I can’t seem to make it happen…

{exp:user:stats}
{categories}
{exp
:weblog:entries weblog="press-releases" category="{category_body}{category_id}{/category_body}" limit="5" disable="member_data|trackbacks" dynamic="off"}
<div class="teaser">
<
h3><a title="{title}" href="{path=news-and-events/press-releases}{entry_id}/{url_title}">{title}</a></h3>                
<
class="newsMeta">{entry_date format="%d %F %Y"}</p>
</
div>
{/exp:weblog:entries}
{
/categories}
{
/exp:user:stats} 

...any idea what I’m doing wrong? For clarity… I have a weblog called press-releases which is assigned to the same category group as that which is specified in the user module prefs pane for users. I’ve logged in and edited my profile to assign myself to a number of categories in this category group so I was expecting the weblog entries tag to only display those entries that are assigned to these categories but it shows everything… :?

Profile
 
 
Posted: 27 January 2010 10:04 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  8223
Joined  2006-10-18

You’ll likely need to use an embed Nate smile

{exp:user:stats}
{categories}
{category_body}
{embed
="path_to/embedded_template" category_id="{category_id}"}
{
/category_body}
{
/categories}
{
/exp:user:stats} 

Embed:

{exp:weblog:entries weblog="press-releases" category="{embed:category_id}" limit="5" disable="member_data|trackbacks" dynamic="off"}
<div class="teaser">
<
h3><a title="{title}" href="{path=news-and-events/press-releases}{entry_id}/{url_title}">{title}</a></h3>                
<
class="newsMeta">{entry_date format="%d %F %Y"}</p>
</
div>
{/exp:weblog:entries} 
 Signature 
Profile
 
 
Posted: 28 January 2010 03:29 AM   [ Ignore ]   [ # 2 ]
Member
Avatar
RankRankRank
Total Posts:  106
Joined  2006-12-12

Hi Kelsey, this works but it repeats the weblog entries loop for each category so instead I ended up going with:

{embed="path_to/embedded_template" category_id="{exp:user:stats log_views="off"}{categories}{category_body}{category_id}|{/category_body}{/categories}{/exp:user:stats}"

Thanks for pointing me in the right direction though! smile

Profile
 
 
Posted: 28 January 2010 04:40 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  8223
Joined  2006-10-18

Yeah, yu can do that… I just wasn’t sure if the extra pipe “|” was going to cause any trouble or not smile

 Signature 
Profile
 
 
Posted: 29 January 2010 01:50 AM   [ Ignore ]   [ # 4 ]
Member
Avatar
RankRankRank
Total Posts:  106
Joined  2006-12-12

No trouble at all. smile

Profile