14
votes
How can I create a visually weighted tag cloud?
Marion Newlevant had a clever, efficient idea in this Straight Up Craft Hangout if you don't mind having a slight lag (like a day) for your tag counts to be up to date. That idea: store the counts you ...
14
votes
Removing whitespace from {{ tag.name }}
Craft has a filter for "Kebab Case", which I think is what you need. It strips out punctuation and replaces spaces with dashes. Useful if you need to format a field as a HTML attribute.
{{ tag.name|...
6
votes
Deleting unused tags
There currently isn't any Tag management in Craft, but if you think there should be, consider voting for this feature request.
In the meantime, there is a 3rd party plugin called Tag Manager that ...
6
votes
Accepted
How do I add a value to a tag field type using the entries service saveEntry method?
The Tags field classifiedTags needs an array of tag IDs, not slugs/titles. Also, if this is an existing entry and you want to retain tags already added to the field, you'll need to pull the existing ...
5
votes
Accepted
Query Entries by Tag
You'd need to get the tag model first.
{% set tag = craft.tags.search('My Tag').first() %}
{% if tag %}
{% set entries = craft.entries.relatedTo(tag) %}
{% endif %}
Replace search with whatever ...
5
votes
Accepted
.relatedTo() not returning tags with spaces
In your working example, you’re mapping request.tags to the search param, but in the non-working example, you’re mapping it to the slug param.
Those two params are handled in very different ways. ...
5
votes
How do I UNLOCK my account?
If you don’t have access to another admin account, you could unlock the account directly in the database.
Change the lock value to 0 for the account in the craft_users table.
5
votes
Accepted
Confused about tags
You told Craft to look for tags/_tag
And then you created templates/tags/_tags.html
Note you have no s on the end in the route definition, but you do in the template name.
5
votes
Accepted
SEO titles/descriptions for tags and archive pages
The better approach in my opinion is to declare the variables in the corresponding templates rather than in the _layout template
Layout.twig
{% if seoTitle is not defined or seoTitle is empty %}
...
5
votes
Still not able to manage tags in Craft 3?
Short answer is "no, this still isn't possible".
Longer answer is:
The Tag Manager plugin from Craft 2 will not be ported.
Pixel & Tonic have mentioned the possibility of rolling that ...
5
votes
How to delete tags in Craft CMS 3
Yes the same still applies. You can either delete it via DB directly in your {{%elements}} column or you can just run
PHP
Craft::$app->getElements()->deleteElementById(x)
Twig
{% do craft....
5
votes
Accepted
How to delete tags in Craft CMS 3
I do believe this plugin can help?
https://github.com/ethercreative/tags
4
votes
Listing All tags - and linking them to list of entries with that tag
You don't have a setting in Craft to make Tags have their own pages automatically. So what you have to do instead, is to set up a dynamic route in Settings → Routes. Create a new route which routes ...
4
votes
Accepted
How do I display tags comma separated with "and" between the last two tags?
Bit of an old question, but here's a (subjectively) more elegant solution than the accepted answer using loop.revindex0:
{% for tag in tags %}
{{ tag.type }}{{ loop.revindex0 == 1 ? ' and' : loop....
4
votes
Plugin: Tags field for front-end Entry Form
While the full answer to this probably requires some planning, and a plugin that handles various aspects of the tag management, here are a few components to consider:
You can submit tags from the ...
4
votes
Accepted
Show all tags related to a category?
You can use the relatedTo param on craft.tags like you can with any Element inside Craft.
All Elements inside Craft can be related to one another. There is a .relatedTo parameter available on all of ...
4
votes
List entries for a single tag from blog section
You were very close! You are looping through craft.entries.section('blog') which doesn't use your tag query. You simply need to loop through the results of your query which you've set in the entries ...
4
votes
Accepted
How to display number of entries for a tag and not display if no entries?
Something like this should work:
{% set tags = craft.tags.limit(null).relatedTo(craft.entries.limit(null)).order('title') %}
{% for tag in tags %}
<a href="/tags/{{ tag.slug }}">{{ tag....
4
votes
Accepted
Where are tags stored in the database?
Tags are Elements and are stored in multiple places in the database, so editing the db directly may not be as easy as just finding the Tags you want and deleting them.
The tag itself is stored in ...
3
votes
Tag mysteriously not found
You don't need to use the search parameter in this case. I'd avoid using it where ever possible.
{% set tag = craft.tags.slug(slug).first() %}
3
votes
I would like to implement the remarketing tag into my website
I assume you're asking about AdWords?
Forgive me if I need to ask this but who developed your website? It sounds like you need to have your developer add that bit to the website's code. (If you're ...
3
votes
Accepted
Limit search results for users by tag (and limit to 5 tags)
There’s no way to tell the relatedTo param to only factor in the first X relations per source element (the first 5 tags per user, in this case).
I can think of two ways you could accomplish this:
...
3
votes
Accepted
Correct way to merge craft.user field arrays and use outside the loop?
It looks like you have a typo in your merge, and the structure of the merge is incorrect.
{% set merged = specialisms|merge(specialisms) %}
This is saying set merged to the array specialisms merged ...
3
votes
How do I delete a tag?
There is a third-party plugin called Tag Manager that let's you delete tags.
3
votes
Accepted
Use of tag.slug instead of tag.title in a custom route
You do not have to change your route. Instead modify your template where you are linking the tag.
Instead of using
<a href="{{ siteUrl }}tags/{{ tag.title | url_encode }}">{{ tag.title }}, <...
3
votes
Accepted
Tag overview in the Craft backend
There is a Tag Manager plugin you can use for this.
You might also want to consider voting for this feature request if you think this should be in core!
3
votes
Accepted
Best method to handle %20 in tag URLs with multiple words
Update.
After looking at the tag model a little more closely, it looks like tags have both a title and slug — so if you use the slug to construct your url then you shouldn't have that problem.
For ...
3
votes
Accepted
List entries without specific tag
You could try something like following reducing the tagged entries into IDs that you then filter against (see this thread):
{% set tag = craft.tags.search('All-Stars').first() %}
{% set allEntries = ...
3
votes
Most related articles
If you're only trying to find related articles based on elements (ie tags, categories, entries, etc), you can use my Similar plugin.
Here's a basic example, more info in the repo:
{% set ...
3
votes
Accepted
Get random entry tagged with
You could try customizing the order parameter. MySQL allows ordering randomly by using .. ORDER BY rand(). So you could try the following:
craft.entries.section('featured').order('rand()').first()
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
tags × 139templating × 19
entries × 19
categories × 14
craft3 × 11
relations × 11
search × 8
entry × 7
plugin-development × 6
routes × 6
frontend-form × 5
users × 4
localization × 4
form × 4
assets × 3
matrix × 3
plugins × 3
url × 3
admin × 3
forloop × 3
query × 3
relatedto × 3
ordering × 3
group × 3
filtering × 3