- Posts: 15
COMMUNITY FORUM
k2 tools - tags by name and not popularity?
- Kogos Grain
-
Topic Author
- Offline
- New Member
Less
More
9 years 2 months ago #151345
by Kogos Grain
k2 tools - tags by name and not popularity? was created by Kogos Grain
Hi,
i'm using k2 tools module (tag cloud) to show 10 tags, but i'd like to show them alphabetically and not by popularity. However, if in k2 tools BE, there is an option to set the numbers of tags to show by popularity only. I tried to figure out what to change in helper.php file, or maybe make a tags.php overide, with no luck.
I know that showing tags by name is not a tag cloud anymore, but it's more of a "tag list" module, but can it be done with k2 tools or any other module? ( I must say, i looked in JED for a tag list module, but couldn't find one).
Thanks in advance
i'm using k2 tools module (tag cloud) to show 10 tags, but i'd like to show them alphabetically and not by popularity. However, if in k2 tools BE, there is an option to set the numbers of tags to show by popularity only. I tried to figure out what to change in helper.php file, or maybe make a tags.php overide, with no luck.
I know that showing tags by name is not a tag cloud anymore, but it's more of a "tag list" module, but can it be done with k2 tools or any other module? ( I must say, i looked in JED for a tag list module, but couldn't find one).
Thanks in advance
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 2 months ago #151348
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic k2 tools - tags by name and not popularity?
You can use PHP's sort function - php.net/sort - in your overrides.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Kogos Grain
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 15
9 years 2 months ago - 9 years 2 months ago #151355
by Kogos Grain
Replied by Kogos Grain on topic k2 tools - tags by name and not popularity?
i'm afraid it's not working... I addedbefore foreach statement, but again, it's not changing anything
Let me explain a bit more what i want to do here... Let's say i got tags named tag1, tag2, tag3, tag4, tag5. Tag1 and tag5 are more popular than the other tags. I set k2tools module to display only 2 modules, and it shows tag1 and tag5, but i want it to show tag1 and tag2 (first 2 tags that it'll find in the array).
Actually, what i need is a simple list of all tags, sorted alphabetically (or reverse alphabetically) that i can choose how many of them will show in frontnend
Can it be done?
<?php sort($tags);?>
Let me explain a bit more what i want to do here... Let's say i got tags named tag1, tag2, tag3, tag4, tag5. Tag1 and tag5 are more popular than the other tags. I set k2tools module to display only 2 modules, and it shows tag1 and tag5, but i want it to show tag1 and tag2 (first 2 tags that it'll find in the array).
Actually, what i need is a simple list of all tags, sorted alphabetically (or reverse alphabetically) that i can choose how many of them will show in frontnend
Can it be done?
Last edit: 9 years 2 months ago by Kogos Grain.
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Moderator
Less
More
- Posts: 8743
9 years 2 months ago #151382
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic k2 tools - tags by name and not popularity?
@Kogos Grain
This cannot be changed. The module is fetching the tags sorted by tagged items number. You need a different module for that.
This cannot be changed. The module is fetching the tags sorted by tagged items number. You need a different module for that.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Kogos Grain
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 15
9 years 2 months ago - 9 years 2 months ago #151402
by Kogos Grain
Replied by Kogos Grain on topic k2 tools - tags by name and not popularity?
yeah, i thought so... i tried to dig a little dipper and i found a work around that seems to be working, without hacking any core files, just with a tag.php override...
so i'm posting the work around solution here, just in case somebody else needs it:
I added a huge Tag limit (X most popular) in modules settings (f.e. 30000). That means that practically the module will NOT filter any tags, unless we have more than 30000 tags (extremely rare). Now, in tags.php, i replaced:
with:
Of course, 9 is the number of tags to show, so it'll need to be changed to the number of tags to show.
Also, if somebody needs to show them in reverse alphabetically order (like me), this line needs to change to this:
Actually, what this does is take the full array of tags, without filtering it by popularity, and force slice it.
This seems to work, but any comments are welcome :)
so i'm posting the work around solution here, just in case somebody else needs it:
I added a huge Tag limit (X most popular) in modules settings (f.e. 30000). That means that practically the module will NOT filter any tags, unless we have more than 30000 tags (extremely rare). Now, in tags.php, i replaced:
<?php foreach ($tags as $tag): ?>
with:
<?php foreach (array_slice($tags, 0, 9, false) as $tag): ?>
Of course, 9 is the number of tags to show, so it'll need to be changed to the number of tags to show.
Also, if somebody needs to show them in reverse alphabetically order (like me), this line needs to change to this:
<?php foreach (array_slice(array_reverse($tags), 0, 9, false) as $tag): ?>
Actually, what this does is take the full array of tags, without filtering it by popularity, and force slice it.
This seems to work, but any comments are welcome :)
Last edit: 9 years 2 months ago by Kogos Grain.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 2 months ago #151404
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic k2 tools - tags by name and not popularity?
Kudos :)
This is a robust solution.
This is a robust solution.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Moderator
Less
More
- Posts: 8743
9 years 2 months ago #151417
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic k2 tools - tags by name and not popularity?
@Kogos Grain
The only issue i see in your solution is performance related. If you have a really big number of tags this might slow down your page a bit. So just make sure that module caching is enabled.
The only issue i see in your solution is performance related. If you have a really big number of tags this might slow down your page a bit. So just make sure that module caching is enabled.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.