2 of 2
2
Category show_empty=“no” behaviour to act according to weblog context
Posted: 22 September 2008 06:54 PM   [ Ignore ]   [ # 19 ]  
Summer Student
Avatar
Total Posts:  9
Joined  05-25-2008

I will add my name to this feature request. Thanks to wolfram for directing me here. As new as I am to EE, I’m even newer to the world of SQL, so I have questions. Please feel free to direct me elsewhere if this is too tedious:

1) Where would either of these (slapshotw or Phire_SK) entries go in the code: just before the section that asks for the categories? In lieu of that section?

2) If I have a variable “my_template_group”, does that take the place of “template group” in the code below:

<a href="{path=template_group}tags/{cat_url_title}">{cat_name}</a><br />


or should I leave that alone?

3) Does the number of categories I have matter?

Let’s start there. I may be able to figure this out once I’m at least a little of the way down the path.

Thanks for any help.

Profile
 
 
Posted: 23 September 2008 07:20 AM   [ Ignore ]   [ # 20 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  156
Joined  07-08-2008

To reply to you Haydar:

1) You would put that code where you would have had otherwise put your {exp:weblog:catrgories} tag.  So you replace the tags, the starting and ending.

2) The EE variables in the line you posted are either part of the SQL statement or your actual page.  template_group is the same as my_template_group or whatever tag you declared to hold that information.  As for cat_name and cat_url_title, they are from the SQL statement itself, take a look at it and you will see them there.

3) I didn’t have any issue with the number of categories.  The code will grab them all as long as they fit the criteria.

Hope that helps.

Profile
 
 
Posted: 23 September 2008 11:10 PM   [ Ignore ]   [ # 21 ]  
Summer Student
Avatar
Total Posts:  9
Joined  05-25-2008

Thank you! I will have to figure out how and why this works later, as I educate myself about queries. But I now have a list in the sidebar that’s unique to the weblog I’m using for this template. I’m almost there.

Let’s say I have two posts on my index page for this template, one tagged “Orientation” and one tagged “Independent Schools”. What I would like is that when someone clicks on, say, the Orientation tag in the sidebar, a page of *only* those posts tagged with Orientation show. With this code:

<a href="{path={my_template_group}/index/{cat_url_title}}">{cat_name}</a><br />

both posts show.

This is different behavior from my other template pages which are using the old code (an embed)  I replaced with yours and slapshotw’s:

{exp:weblog:categories weblog="{embed:my_weblog}" style="nested" show_empty="no"}
    
<a href="{path={embed:my_template_group}/index}">{category_name}</a>
{/exp:weblog:categories}

where selecting a tag in the sidebar results the behavior I wish (only 1 post in this case).

What am I doing wrong here?

Profile
 
 
Posted: 24 September 2008 06:58 AM   [ Ignore ]   [ # 22 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  156
Joined  07-08-2008

I’m not 100% sure what you are asking but I’m assuming it is just a linking issue?  Just replace {my_weblog} and {my_template_group} with your embed version.  Then it should link to what you want.

P.S. nice lion smile

Profile
 
 
Posted: 24 September 2008 11:22 PM   [ Ignore ]   [ # 23 ]  
Summer Student
Avatar
Total Posts:  9
Joined  05-25-2008

Thanks again.

OK, I don’t think I was clear. Here’s what I had to do finally to make the url work:

<a href="{path={my_template_group}/index/{cat_url_title}/C{cat_id}}">{cat_name}</a><br />

This really feels like a hack, I don’t like it, even though it works. Adding the

C{cat_id}

gave me a url like this:

http://www.wmscounseling.org/index.php/8th-grade/independent-schools/C37/

which then gave me only the entries which were tagged with category 37 (independent schools). This is what I was getting with my old code (minus the cat_url_title), I just had ID #s) which didn’t have any kludges at all (but which, of course, listed every category from every weblog). That is, the C37 (or whatever ID) was generated automatically from the code I posted yesterday.

Maybe this example will clarify what I’m looking for. If so, can you tell me how to make this happen in a more elegant way?

Thanks for your help. I really appreciate it. I’m trying to understand the concepts here and not just get the templates to work.

PS: The lion is a graphic from Kenya.

Profile
 
 
Posted: 23 October 2008 10:30 PM   [ Ignore ]   [ # 24 ]  
Summer Student
Avatar
Total Posts:  9
Joined  05-25-2008

I did some independent reading on MySQL commands, and discovered that if I add this line to the end of the code:

ORDER BY cat_name ASC

the categories will stay in order alphabetically as they are added to the weblog.

Thanks again to those who’ve helped me with this. I’m still waiting for the next version of EE to give the option of doing this without going through all this, but for now, this works.

Profile
 
 
Posted: 04 November 2008 03:09 PM   [ Ignore ]   [ # 25 ]  
Summer Student
Total Posts:  8
Joined  04-11-2008

This feature request is Uber-necessary!!! I’m also vexed by this behavior… I’m like, c’mon EE, you’re better than that dog! =)

There’s no workaround for this except to involve the Query module and even then I’m just assuming it would work, I haven’t tried yet. But no luck on that note for those who are using the core version.

Profile
 
 
Posted: 04 November 2008 05:35 PM   [ Ignore ]   [ # 26 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  371
Joined  10-18-2004

I would like to express my support for this feature request. Like others in this thread, I expected the {exp:weblog:categories} tag to work like this already, and was quite surprised when I found out it didn’t.

In other words: oh hai! plz fix… kthxbai. wink

 Signature 

Low: the Pro Network member who brought you the File Manager Module, Yearly Archives Plugin, Find & Replace Plugin, Akismet Combo, and more…

Profile
 
 
Posted: 25 November 2008 04:26 PM   [ Ignore ]   [ # 27 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  156
Joined  07-08-2008

I made a new version of this to hack the feature request.  This version mimics the current functionality of the exp:weblog:categories tag almost exactly (with the feature request included).  It is in non-linear format, so it keeps the list format.

This requires PHP to be set as OUTPUT for the template.

{exp:weblog:entries limit="1" weblog="put_weblog_name_here"}
    
<ul>
    
{exp:query sql="
        SELECT DISTINCT t1.cat_url_title, t1.cat_name, t2.cat_id, t3.weblog_id
        FROM exp_categories t1, exp_category_posts t2, exp_weblog_titles t3
        WHERE t1.cat_id = t2.cat_id
            AND t2.entry_id = t3.entry_id
            AND t3.weblog_id = '{weblog_id}'
            AND t1.parent_id = 0
        ORDER BY t1.cat_name
    "
}
        
<li><a href="{path=put_template_here/put_weblog_here}{cat_url_title}">{cat_name}</a>
        
<?
            
global $DB;
            
            
$sql = "SELECT DISTINCT t1.cat_url_title AS subcat_url_title, t1.cat_name AS subcat_name
                    FROM exp_categories t1, exp_category_posts t2, exp_weblog_titles t3
                    WHERE t1.cat_id = t2.cat_id
                        AND t2.entry_id = t3.entry_id
                        AND t3.weblog_id = '{weblog_id}'
                        AND t1.parent_id = {cat_id}
                    ORDER BY t1.cat_name"
;
            
            
$query = $DB->query($sql);
            if (
$query->num_rows > 0)
            
{
                
echo "<ul>";
                foreach(
$query->result as $row)
                
{
                    
echo '<li><a href="{path=put_template_here/put_weblog_here}'.$row['subcat_url_title'].'">'.$row['subcat_name'].'</a></li>';
                
}
                
echo "</ul>";
            
}
        
        ?>
        
</li>
    
{/exp:query}
    
</ul>
{/exp:weblog:entries}

Make sure to replace all the “put_…” areas of the code with your site’s info.

Profile
 
 
   
2 of 2
2
 
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: 65027 Total Logged-in Users: 41
Total Topics: 82116 Total Anonymous Users: 23
Total Replies: 441311 Total Guests: 185
Total Posts: 523427    
Members ( View Memberlist )