T3Social / NgineS

The Ultimate PHP Social Network Platform
GNU Affero General Public License v3.0
1 stars 0 forks source link

Issue: Not assigne Blog Categories show up in sidebar #92

Closed lisandi closed 3 years ago

lisandi commented 3 years ago

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.

Unassigned Blog Categories show in right sidebar

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

lisandi commented 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 -->

Categories list 107

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 -->

Categories options 107

Categories Options Category view

Categories options no articles

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 -->

Categories list 381 single view

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 -->

Categories options 381-374 single view

Categories options single view

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>

Categories options example

lisandi commented 3 years ago

https://github.com/T3Social/Sngine-Community-Edition/wiki/How-to-show-Blog-Categories-in-an-Option-Dropdown-Menu-instead-of-a-list-in-Sngine