9

I want to create a menu item for a tag that shows the articles as in category blog layout. I have tried with these menu item types: "Compact List of Tagged Items", "List of all tags" and "Tagged Items" but with no luck.

According to the official documentation of content tags, it seems to be possible.

Once you have tags and some tagged items you can display them in the front end in several ways.

By default Joomla! will display tags embedded in each item that has been tagged. You can turn this display off by changing the parameters. You can control positioning of this display with layout overrides and alternate layouts and you can style it with your css.

You can create a menu link that displays a list of tags, with links to the tagged items for each tag.

> You can create a menu link that displays a list of tagged items for a given tag and display either as a list or blog style.

You can use one of the tags modules. Popular tags will display a linked list of the tags that have the most tagged items. Similar Tags will display a list of items that have a similar set of tags to the currently displayed item (note that this module does not display on pages that are not showing content items).

3 Answers 3

12

Since this problem seems has been already asked several times and there is still no good answer for that, I'd like to try to provide my solution from the template override side. The steps are quite complex but it should be easy.

Note : I'm using Joomla 3.4.4 and template protostar while creating this tutorial

First, copy this files :

[root]/components/com_tags/views/tag/tmpl/default.php
[root]/components/com_tags/views/tag/tmpl/default.xml
[root]/components/com_tags/views/tag/tmpl/default_items.php

to

[root]/templates/your_template_name/html/com_tags/tag/default.php
[root]/templates/your_template_name/html/com_tags/tag/default.xml
[root]/templates/your_template_name/html/com_tags/tag/default_items.php

replace the file names to something you like, for example 'taggedblog', so it will become :

[root]/templates/your_template_name/html/com_tags/tag/taggedblog.php
[root]/templates/your_template_name/html/com_tags/tag/taggedblog.xml
[root]/templates/your_template_name/html/com_tags/tag/taggedblog_items.php

Open the file [root]/templates/your_template_name/html/com_tags/tag/taggedblog.xml at the top of file you will see this code :

<layout title="com_tags_tag_view_default_title" option="com_tags_tag_view_default_option">

change that to

<layout title="Tagged Blog" option="taggedblog">

At this point, you should see a new menu item type called Tagged Blog when creating a new menu item from your menu manager. See this image below

New Tagged Blog Menu Item

Now, Open file [root]/templates/your_template_name/html/com_tags/tag/taggedblog_items.php

at lines 62 delete this code :

<ul class="category list-striped">

and it's </ul> closing tag at lines 90

then, still on the same file, delete these codes started at lines 64:

<?php if ($item->core_state == 0) : ?>
                <li class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
            <?php else: ?>
                <li class="cat-list-row<?php echo $i % 2; ?> clearfix" >

<?php endif; ?> at lines 70, and closing tag </li> at lines 85

Next, add <div class="span5"> at 64 lines after the code <?php foreach ($items as $i => $item) : ?> and add closing </div> before the <?php endforeach; ?>

Next, arround lines 77 before the code <?php if ($this->params->get('tag_list_show_item_description', 1)) : ?> add this code :

<?php
    $db = JFactory::getDBO();
    $query = $db->getQuery(true);
    $query->select('introtext')->from('#__content')->where('id=' . (int)$item->content_item_id);
    $db->setQuery($query);
    //displaying the intro image
    $images  = json_decode($item->core_images);
    if(!empty($images->image_intro)) {
        echo '<img src="'.$images->image_intro.'">';
    }
    //displaying the intro text
    $introtext = $db->loadResult();
    echo $introtext;

    ?>

At this point, introtext and intro image should have been displayed on the the website.

Now, open the file [root]/templates/your_template_name/html/com_tags/tag/taggedblog.php , around lines 51 you will see this code <?php echo $this->loadTemplate('items'); ?> , change that line to :

<div class="row"><?php echo $this->loadTemplate('items'); ?></div>

That's all.

Now try to create a menu item with Tagged Blog type from your joomla menu manager, and see the result.

To make things easier, I have uploaded those files above in here. Have fun!

1
  • 2
    I can't believe this feature has not yet been implemented. Sep 25, 2015 at 16:35
2

This is not currently possible. The closest you can get is Tagged Items. There is an article in the Joomla Forums about how to add the read more. http://forum.joomla.org/viewtopic.php?f=708&t=838191

This is also currently a request on ideas.joomla.org at http://ideas.joomla.org/forums/84261-joomla-idea-pool/category/12057-content?query=category%20blog%20tagged%20items. You can go and vote for it to be included.

0

In March 2019, this is still seemingly a problem.... A different approach might be to use your web server's (Apache/ngnix/IIS/etc) redirection to catch the "standard" links and redirect them to your own links. The downsides (as I see them) are: - access to the relevant configuration files for the web server (for Apache, this can be done in the per-directory .htaccess, so long as mod_rewrite enabled) - you have a manageable number of tags to allow you to create a destination menu item for each one (if you have 200 tags, you could create menu items for each one, but who would bother?) The Apache rewrite rules I'm using for this are:

RewriteBase /
ReWriteRule ^component/tags/tag/([^\.]+).html$ /$1-articles [L,R=301]

So, for each tag, I have a destination article in the format I want accessed by a menu item with the tag name and -articles (for example, tag1-articles). Sure, it's a workaround, but I have got the result I wanted given I can meet the two "conditions" (Apache config access and not many tags) above.

Not the answer you're looking for? Browse other questions tagged or ask your own question.