Closed lisandi closed 3 years ago
You need to change the way the categories show up.
To present them in an option menu replace the existing code start line 107 which lists all categories as a list on the categories page where all articles for one specific category get listed
<!-- blogs categoris -->
<div class="articles-widget-header">
<div class="articles-widget-title">{__("Categories")}</div>
</div>
<ul class="article-categories clearfix">
{foreach $blogs_categories as $category}
<li>
<a class="article-category" href="{$system['system_url']}/blogs/category/{$category['category_id']}/{$category['category_url']}">
{$category['category_name']}
</a>
</li>
{/foreach}
<li>
<a class="article-category" href="{$system['system_url']}/blogs/category/0/Uncategorized">
{__("Uncategorized")}
</a>
</li>
</ul>
<!-- blogs categoris -->
to an option dropdown menu with the linked categories and the one chosen as the selected one and if no article is available it shows "No articles available. Select new Category.
<!-- blogs categoris -->
<div class="articles-widget-header">
<div class="articles-widget-title">{__("Categories")}</div>
</div>
<div>
<select class="form-control" name="category" onchange="location = this.value;">
<option>{__("No articles available. Select new Category.")}</option>
{foreach $blogs_categories as $category}
<option value="../{$category['category_id']}/{$category['category_url']}" {if $article['article']['category_id'] == $category['category_id']}selected{/if}>{__($category['category_name'])}</option>
{/foreach}
</select>
</div>
<!-- blogs categoris -->
and the categories in the single article view sidebar start line 381 (in original unmodified template)
<!-- blogs categoris -->
<div class="articles-widget-header">
<div class="articles-widget-title">{__("Categories")}</div>
</div>
<ul class="article-categories clearfix">
{foreach $blogs_categories as $category}
<li>
<a class="article-category" href="{$system['system_url']}/blogs/category/{$category['category_id']}/{$category['category_url']}">
{$category['category_name']}
</a>
</li>
{/foreach}
<li>
<a class="article-category" href="{$system['system_url']}/blogs/category/0/Uncategorized">
{__("Uncategorized")}
</a>
</li>
</ul>
<!-- blogs categoris -->
to
<!-- blogs categoris -->
<div class="articles-widget-header">
<div class="articles-widget-title">{__("Categories")}</div>
</div>
<div>
<select class="form-control" name="category" onchange="location = this.value;">
<option>{__("Select Category")}</option>
{foreach $blogs_categories as $category}
<option value="../category/{$category['category_id']}/{$category['category_url']}" {if $article['article']['category_id'] == $category['category_id']}selected{/if}>{__($category['category_name'])}</option>
{/foreach}
</select>
</div>
<!-- blogs categoris -->
you can use the option menu code which is already available start line 491 which helps you also to present the current category name as the one selected in the sidebar.
<div class="form-group form-row">
<label class="col-md-2 form-control-label">
{__("Category")}
</label>
<div class="col-md-10">
<select class="form-control" name="category">
<option>{__("Select Category")}</option>
{foreach $blogs_categories as $category}
<option value="{$category['category_id']}" {if $article['article']['category_id'] == $category['category_id']}selected{/if}>{__($category['category_name'])}</option>
{/foreach}
</select>
</div>
</div>
Blog Categories which have no Blog Post assigned still show up in the right sidebar.
This results in empty post pages which are pretty annoying!
Solution would be to show in the right Category field in sidebar right only categories which have been assigned to at least one post.
I suggest you integrate a Tag could which shows the 10 most used categories instead and additional a simple option dropdown to list all categories. That way it shows the most used categories but also enabled the user to choose still from other categories and for SEO those options will still help ;-) as they are in source code available which gets read by search engines.
Wiki
https://github.com/T3Social/T3Social-Community/wiki/How-to-show-Blog-Categories-in-an-Option-Dropdown-Menu-instead-of-a-list-in-Sngine-and-T3Social