Category Icons in sidebar

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Fishy
Regular
Posts: 7
Joined: Sun May 26, 2024 8:01 pm

Category Icons in sidebar

Post by Fishy »

Could anyone please help me put the category icon into the sidebar?

I managed to place the category icon in the top right corner of the entry title, but i cannot put that same code into the plugin_categories.tpl to make it work.

I know we used to be able to do it about 10 years ago or so, but I cannot remember or find my notes on it.

Current version
Theme = i3Theme
Attachments
categories_entries.png
categories_entries.png (12.56 KiB) Viewed 902 times
categories.png
categories.png (10.34 KiB) Viewed 902 times
onli
Regular
Posts: 2836
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Category Icons in sidebar

Post by onli »

That's the category display as painted by the sidebar plugin, right?

In that case, did you already activate smarty templating in the options of the plugin? Then you should be able to add code to the used `plugin_categories.tpl`.

Or is that the step where you are already, and the code just does not work?
Fishy
Regular
Posts: 7
Joined: Sun May 26, 2024 8:01 pm

Re: Category Icons in sidebar

Post by Fishy »

Yes, the smarty stuff is allready enabled.
I copied the icon code from entries or somewhere, and placed it somewhere in the plugin_categories.tpl, probably the wrong location and the wrong icon if statement with span

is that right? Or could you show me which code i can copy for the icon in the category list.
onli
Regular
Posts: 2836
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Category Icons in sidebar

Post by onli »

I'm honestly not sure how I'd solve this, haven't done so in my blog. Could you share the code you used so far? I can at least compare with the logic in the plugin .tpl, maybe that helps.
Fishy
Regular
Posts: 7
Joined: Sun May 26, 2024 8:01 pm

Re: Category Icons in sidebar

Post by Fishy »

Get the icon next to the entry title

This is in the entries.tpl in the default template.

Code: Select all

        <h4 class="serendipity_title"><a href="{$entry.link}">{$entry.title}</a></h4>

        <div class="serendipity_entry serendipity_entry_author_{$entry.author|@makeFilename} {if $entry.is_entry_owner}serendipity_entry_author_self{/if}">
            {if $entry.categories}
            <span class="serendipity_entryIcon">
            {foreach from=$entry.categories item="entry_category"}
                {if $entry_category.category_icon}
                    <a href="{$entry_category.category_link}"><img class="serendipity_entryIcon" title="{$entry_category.category_name|@escape}{$entry_category.category_description|@emptyPrefix}" alt="{$entry_category.category_name|@escape}" src="{$entry_category.category_icon|escape}" /></a>
                {/if}
            {/foreach}
            </span>
            {/if}

            <div class="serendipity_entry_body">
                {$entry.body}
            </div>

Then i was thinking to take the icon if statement from above and place it somewhere over here

Code: Select all

    <ul id="serendipity_categories_list" style="list-style: none; margin: 0px; padding: 0px">
{foreach from=$categories item="plugin_category"}
        <li class="category_depth{$plugin_category.catdepth} category_{$plugin_category.categoryid}" style="display: block;">
        {if $is_form}    
            <input style="width: 15px" type="checkbox" name="serendipity[multiCat][]" value="{$plugin_category.categoryid}" />
        {/if}
    
        {if !empty($category_image)}
            <a class="serendipity_xml_icon" href="{$plugin_category.feedCategoryURL}"><img src="{$category_image}" alt="XML" style="border: 0px" /></a>
        {/if}
------like right here after the XML icon but before the category title

            <a href="{$plugin_category.categoryURL}" title="{$plugin_category.category_description|escape}" style="padding-left: {$plugin_category.paddingPx}px">{$plugin_category.category_name|escape}</a>
        </li>
{/foreach}
    </ul>
onli
Regular
Posts: 2836
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Category Icons in sidebar

Post by onli »

Did you rename the variable? Like from this:

Code: Select all

{if $entry_category.category_icon}
    <a href="{$entry_category.category_link}"><img class="serendipity_entryIcon" title="{$entry_category.category_name|@escape}{$entry_category.category_description|@emptyPrefix}" alt="{$entry_category.category_name|@escape}" src="{$entry_category.category_icon|escape}" /></a>
{/if}
to, since the plugin_sidebar.tpl has no $entry_category:

Code: Select all

{if $plugin_category.category_icon}
    <a href="{$plugin_category.category_link}"><img class="serendipity_entryIcon" title="{$plugin_category.category_name|@escape}{$plugin_category.category_description|@emptyPrefix}" alt="{$plugin_category.category_name|@escape}" src="{$plugin_category.category_icon|escape}" /></a>
{/if}
You should also debug how $plugin_category is filled, by adding {$plugin_category|@print_r} to your tpl. But based on the code, the .category_icon should be available.
Fishy
Regular
Posts: 7
Joined: Sun May 26, 2024 8:01 pm

Re: Category Icons in sidebar

Post by Fishy »

nope still cannot get it to work.
tried various combinations of this "plugin_category.category_icon"

even tried to read through the lang/en files
also tried the {$plugin_category|@print_r}, but it produced nothing that i could see

i am stuck :?
onli
Regular
Posts: 2836
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Category Icons in sidebar

Post by onli »

One more question before I debug this in my dev blog: Which file exactly are you editing there?
Fishy
Regular
Posts: 7
Joined: Sun May 26, 2024 8:01 pm

Re: Category Icons in sidebar

Post by Fishy »

the plugin_categories.tpl in the default template
onli
Regular
Posts: 2836
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Category Icons in sidebar

Post by onli »

I know that's misleading, but that one isn't used anymore. It's the old default, only used when themes specifically are configured to use it, which yours should not be.

Copy it into your theme directory, or better yet: Copy it from templates/2k11/.
Fishy
Regular
Posts: 7
Joined: Sun May 26, 2024 8:01 pm

Re: Category Icons in sidebar

Post by Fishy »

Like you mean copy the plugin_categories.tpl from templates/2k11/ into the i3theme folder?

Yay! that works 100% thank you :)

just now need to figure out how to move the icons to infront of the title
Attachments
move icons.png
move icons.png (14.03 KiB) Viewed 771 times
Fishy
Regular
Posts: 7
Joined: Sun May 26, 2024 8:01 pm

Re: Category Icons in sidebar

Post by Fishy »

Fantastic, i got it moved.

Needed to add this left in the class

<img class="serendipity_entryIcon_left
onli
Regular
Posts: 2836
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Category Icons in sidebar

Post by onli »

Hey, great :)
Post Reply