Keyword

How to change tag view options?

  • lusi djudjeto
  • lusi djudjeto's Avatar Topic Author
  • Offline
  • New Member
More
6 years 9 months ago #168628 by lusi djudjeto
How to change tag view options? was created by lusi djudjeto
Are there any options for " Item View options in TAG listing"??

I can change only categories settings but not tags settings.

When I click on a tag I'd like to have 2 leaging colums same as category view also item created date.But there are no options to change tags view.

Please Log in or Create an account to join the conversation.

More
6 years 9 months ago #168644 by Nadal Kumar
Replied by Nadal Kumar on topic How to change tag view options?
There is no core method to alter the tag items page. You need a plugin for that, and one exists.

It currently will only set the first item as lead, but it certainly can be updated to set any count for lead items. The parameter is set in the K2 global configuration which can set all tags to display with a lead, or leave the global at no and set the override in the menu item of type K2 tag. See it in action at directory.websitedons.net/k2-tag


Attachments:

Please Log in or Create an account to join the conversation.

More
6 years 9 months ago #168657 by Rivu Biswas
Replied by Rivu Biswas on topic How to change tag view options?
Thank you Nadal. Your procedure worked for me well.

Regards,
Zayn.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169202 by Villy Koutsogianni
Replied by Villy Koutsogianni on topic How to change tag view options?
Hi Nadal
Your plugin seems that resolves the problem of tag display without the need of hacking core files.
Thank you for creating and offering it!

I have followed the link you have provided then clicked on Get the pluging, but I couldn't spot it.

I found Custom Fields And Layout Formatting Shortcodes For Joomla 3 but the one for Tags

Can you please advise?

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169209 by JoomlaWorks
Replied by JoomlaWorks on topic How to change tag view options?
I can confirm there is no direct URL to get the plugin.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago - 6 years 7 months ago #169404 by Villy Koutsogianni
Replied by Villy Koutsogianni on topic How to change tag view options?
It is a pity that for an obvious layout (tag view same as article view) one needs a 3rd party plg (that may not exist anymore) or else to hack the core K2 code.
Last edit: 6 years 7 months ago by Villy Koutsogianni.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169408 by JoomlaWorks
Replied by JoomlaWorks on topic How to change tag view options?
@Villy At some point in the coming updates, more layout options will be added to all secondary views (tag, user, date etc.).

In the meantime, it's dead simple to craft any grid you like by making simple modifications in the output loop of the file tag.php. If you need help, just ask.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169487 by Villy Koutsogianni
Replied by Villy Koutsogianni on topic How to change tag view options?
Hi Foti
Thank you for the reply.
I am sure I have posted here, asking for help but my post is not here anymore (:

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169496 by JoomlaWorks
Replied by JoomlaWorks on topic How to change tag view options?
We haven't deleted any of your posts, that's for sure. Perhaps you had discussed the issue on another forum or Facebook page that's why you can't locate your post here. But in any case, if you need assistance, take a moment to describe your layout again.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169561 by Villy Koutsogianni
Replied by Villy Koutsogianni on topic How to change tag view options?
Maybe I forgot to click Submit :(

So this is what I need to achieve.
The way I display my K2 items is as in the attached image

So, in the tag view I need to display 2 columns, rating, hits and tagged under.
I also would like to use intro world limit instead of read more, as I do in blog layout.

In order to add -also tagged under- I have followed Krikor’s advise in post #167620
In file models/item.php I have added || ($view == 'itemlist' && $task == 'tag') as following
// Tags
		if (($view == 'item' && ($item->params->get('itemTags') || ($view == 'itemlist' && $task == 'tag') || $item->params->get('itemRelated'))) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemTags')) || ($view == 'itemlist' && $task == 'user' && $item->params->get('userItemTags')) || ($view == 'latest' && $params->get('latestItemTags'))) 
		{
			$tags = $this->getItemTags($item->id);
			for ($i = 0; $i < sizeof($tags); $i++)
			{
				$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
			}
			$item->tags = $tags;
		}

Then in file templates/default/tag.php I have added a div
<div class="catItemTags"><span><?php echo JText::_('Also tagged under: '); ?></span>  
	<?php foreach ($this->item->tags as $tag): ?>
<a href="<?php echo $tag->link; ?>"><?php echo $tag->name; ?></a>, 
<?php endforeach; ?>
		 </div>

but with no result.

And what about 2 columns, rating, hits and world limit?

Thank you in advance
Attachments:

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago - 6 years 7 months ago #169567 by JoomlaWorks
Replied by JoomlaWorks on topic How to change tag view options?
The check is simply in the wrong place (it's inside the check in the item view). Revise your code and I'll make sure we update the code in K2 in the coming updates so you don't have to modify the model for the item every time.

Change it to:
<?php

// Tags
if (
    ($view == 'item' && ($item->params->get('itemTags') || $item->params->get('itemRelated'))) ||
    ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemTags')) ||
    ($view == 'itemlist' && $task == 'user' && $item->params->get('userItemTags')) ||
    ($view == 'latest' && $params->get('latestItemTags')) ||
    ($view == 'itemlist' && $task == 'tag') /* Tag layout check */
) {
    $tags = $this->getItemTags($item->id);
    for ($i = 0; $i < sizeof($tags); $i++) {
        $tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
    }
    $item->tags = $tags;
}
Last edit: 6 years 7 months ago by JoomlaWorks.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169568 by Villy Koutsogianni
Replied by Villy Koutsogianni on topic How to change tag view options?
Kalimera Foti, thanks for your reply!
I have corrected the code as you suggested, but still no result.
It displays Also tagged under:
Is something wrong in tag.php?
<div class="catItemTags"><span><?php echo JText::_('Also tagged under: '); ?></span>  
	<?php foreach ($this->item->tags as $tag): ?>
<a href="<?php echo $tag->link; ?>"><?php echo $tag->name; ?></a>, 
<?php endforeach; ?>
		 </div>


Thanks for your patience
Attachments:

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago - 6 years 7 months ago #169571 by JoomlaWorks
Replied by JoomlaWorks on topic How to change tag view options?
Better try this in your tag.php:
<?php if (isset($item->tags) && count($item->tags)): ?>
<div class="catItemTags">
	<span><?php echo JText::_('Also tagged under'); ?>:</span>
	<?php foreach ($item->tags as $tag): ?>
	<a href="<?php echo $tag->link; ?>"><?php echo $tag->name; ?></a>, 
	<?php endforeach; ?>
</div>
<?php endif; ?>
Last edit: 6 years 7 months ago by JoomlaWorks.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169572 by Villy Koutsogianni
Replied by Villy Koutsogianni on topic How to change tag view options?
Thank you so much! Of course, that did the job.
I will try later to add 2 columns, rate, category etc I hope I will manage :)

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169573 by JoomlaWorks
Replied by JoomlaWorks on topic How to change tag view options?
Just copy the setup from category.php. Shouldn't be difficult.

The item tags missing from the tag.php layout was something in our todo list. So given the chance today, I actually merged this into K2 core (in v2.9.1 dev): github.com/getk2/k2/archive/master.zip

I recommend you install on top as there are controls now in place in the K2 Settings for that (first tab there). Item tags in the tag layout will be enabled by default from now on.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago - 6 years 7 months ago #169575 by Villy Koutsogianni
Replied by Villy Koutsogianni on topic How to change tag view options?
What is left now are Hits and Rating.

Just copy the setup from category.php. Shouldn't be difficult.

Do you mean category.item.php?
Copying the parts needed of that file does not work

I suppose I must add an appropriate view check for rating and hits as well. Right?
Last edit: 6 years 7 months ago by Villy Koutsogianni.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169582 by JoomlaWorks
Replied by JoomlaWorks on topic How to change tag view options?
I was referring to the layout grid. This is defined in category.php. In category_item.php is the output for each item in the loops fetching all items.

For hits and rating just get the code from "item.php" and simply swap any instance of "$this->item->" with "$item->".

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169588 by Villy Koutsogianni
Replied by Villy Koutsogianni on topic How to change tag view options?
Hits work fine but rating not.
It displays rating but with no rates at all.
If I vote for an item it then displays its total votes.
Here is the code
<?php if($item->params->get('itemRating')): ?>
      
	<!-- Item Rating -->
	<div class="itemRatingBlock">
		<span><?php echo JText::_('K2_RATE_THIS_ITEM'); ?></span>
		<div class="itemRatingForm">
			<ul class="itemRatingList">
				<li class="itemCurrentRating" id="itemCurrentRating<?php echo $item->id; ?>" style="width:<?php echo $item->votingPercentage; ?>%;"></li>
				<li><a href="#" data-id="<?php echo $item->id; ?>" title="<?php echo JText::_('K2_1_STAR_OUT_OF_5'); ?>" class="one-star">1</a></li>
				<li><a href="#" data-id="<?php echo $item->id; ?>" title="<?php echo JText::_('K2_2_STARS_OUT_OF_5'); ?>" class="two-stars">2</a></li>
				<li><a href="#" data-id="<?php echo $item->id; ?>" title="<?php echo JText::_('K2_3_STARS_OUT_OF_5'); ?>" class="three-stars">3</a></li>
				<li><a href="#" data-id="<?php echo $item->id; ?>" title="<?php echo JText::_('K2_4_STARS_OUT_OF_5'); ?>" class="four-stars">4</a></li>
				<li><a href="#" data-id="<?php echo $item->id; ?>" title="<?php echo JText::_('K2_5_STARS_OUT_OF_5'); ?>" class="five-stars">5</a></li>
			</ul>
			<div id="itemRatingLog<?php echo $item->id; ?>" class="itemRatingLog"><?php echo $item->numOfvotes; ?></div>
			<div class="clr"></div>
		</div>
		<div class="clr"></div>
	</div>
	<?php endif; ?>

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169591 by JoomlaWorks
Replied by JoomlaWorks on topic How to change tag view options?
We probably limit where rating can render for performance reasons. If we do that indeed, it means you're gonna have to change the itemlist model and/or the item model. We're now getting deeper into changing core K2 and it's really beyond the scope of the support we provide here.

Generally speaking, I would implement all these as a plugin to make sure core K2 is not modified and changes/improvements stick after updating K2.

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #169598 by Villy Koutsogianni
Replied by Villy Koutsogianni on topic How to change tag view options?
I totally understand and I thank you for your time and support so far.
This is exactly what I was talking about

It is a pity that for an obvious layout (tag view same as article view) one needs a 3rd party plg (that may not exist anymore) or else to hack the core K2 code.

My hopes, for a future update :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum