Page 1 of 1
Category Icons in sidebar
Posted: Sun May 26, 2024 8:18 pm
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
Re: Category Icons in sidebar
Posted: Tue May 28, 2024 1:13 pm
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?
Re: Category Icons in sidebar
Posted: Tue May 28, 2024 4:15 pm
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.
Re: Category Icons in sidebar
Posted: Tue May 28, 2024 4:18 pm
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.
Re: Category Icons in sidebar
Posted: Tue May 28, 2024 4:25 pm
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>
Re: Category Icons in sidebar
Posted: Tue May 28, 2024 7:46 pm
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.
Re: Category Icons in sidebar
Posted: Tue May 28, 2024 10:06 pm
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

Re: Category Icons in sidebar
Posted: Tue May 28, 2024 10:23 pm
by onli
One more question before I debug this in my dev blog: Which file exactly are you editing there?
Re: Category Icons in sidebar
Posted: Wed May 29, 2024 7:16 am
by Fishy
the plugin_categories.tpl in the default template
Re: Category Icons in sidebar
Posted: Wed May 29, 2024 1:25 pm
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/.
Re: Category Icons in sidebar
Posted: Wed May 29, 2024 4:06 pm
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
Re: Category Icons in sidebar
Posted: Wed May 29, 2024 4:28 pm
by Fishy
Fantastic, i got it moved.
Needed to add this left in the class
<img class="serendipity_entryIcon_left
Re: Category Icons in sidebar
Posted: Wed May 29, 2024 6:18 pm
by onli
Hey, great :)