Hi there, could you elaborate further on your original question? I might be misunderstanding it.
I think you might have to do something custom, but it’s hard to say for sure without more details.
Is what you’re looking for a form in the tooic post, and adds tags to the topic based on the form’s content? Because then you might be able to get away with a Theme Component instead.
If I’m reading your question correctly, it sounds like you use a tag for each client, and you want an extended client description to show up when viewing any topic having that tag.
It’s not a form really, but the Tag Banners component, as seen here on Meta, might get you halfway there:
With this component installed, you can add a text description for each tag that will appear in a banner shown when the tag itself is selected. The text field takes HTML and can be styled with custom CSS so you could do quite a bit with it, but here’s a very plain example where I’m editing a tag:
The challenge would be to alter this component so that it shows up not only on the tag page, but on each topic using that tag. I don’t know how much work that might be, but a more experienced coder (like Nate…) might have some idea.
Ok, since I understood your question I’ll edit the title of this topic so maybe some more people will take a look.
I imagine it would require forking the component to create a new version, figuring out what triggers the banner to appear on the tag page, and changing that so it’s also triggered when tagged topics are viewed.
You could get lucky and someone will think that sounds like fun – otherwise you might need to figure out a project budget and post a request in the Marketplace.
Very cool of you to take this on, Nate. I don’t have the need for it myself, but I was excited to try it out. It works great!
I do see a gotcha, though, when there are multiple tags on a topic. (And it’s hard to imagine managing things with only one tag per topic.)
Tags are either sorted alphabetically or by popularity…
…so the author has no direct control over which tag shows first.
I thought using a non-alpha character to start the client tags (~ClientName) might always pop it to the head of the list. This works on the /tags page – but not on a topic, where the tag list just ignores the ~ character.
In a topic from last year, it appears that certain non-alpha characters could be inserted invisibly to force sorting: Invisible way to force display order of tags? but it seems this doesn’t work now. When I create a tag today with an apostrophe or comma it’s either rejected or silently stripped out. (Not sure why ~ is accepted.)
The tag sort setting shown above affects both the /tags page and the tag list on topics – but I guess they must use a different alpha algorithm?
Hmm… I suppose it really depends what OP wishes to do. If there’s 1 tag → 1 topic → 1 user, then this would work. Otherwise, there’ll have to be more info .
Hmm… I’m not sure if this is completely aligned with the core concept of a ‘tag banner’, since it was meant to display tag info on the tag’s page, but this displays the tag info in topics with the tag .
On a separate note, there have been some updates the main component so I’ll need to try and update the fork as well, but note that the fork is just meant to be a proof-of-concept.
Yeah, I don’t know if it would be widely useful enough to add the features to the original plugin. A separate version or an add-on called “Tagged Topic Banner” might be more appropriate.
But I think the utility is pretty limited unless there’s also some way for the author to specify which tag will be primary. The only things I can think of are…
1.) A hack like making the alpha-sort treat a character like ~ as top-of-list.
AskBot suggested an approach for a plugin monkey-patch
# plugin.rb
after_initialize do
module ::CustomTagSort
def custom_tag_sort(tags)
tags.sort_by do |tag|
# Puts ~-prefixed tags first, then sorts A-Z
[tag.name.start_with?("~") ? 0 : 1, tag.name.downcase]
end
end
end
# Patch into the serializer/method that computes visible_tags or similar
require_dependency 'topic_tags_mixin'
TopicTagsMixin.prepend(Module.new do
private
def all_tags
return @tags if defined?(@tags)
tags = topic.visible_tags(scope)
if SiteSetting.tags_sort_alphabetically
tags = ::CustomTagSort.custom_tag_sort(tags)
else
topic_count_column = Tag.topic_count_column(scope)
tags = tags.sort_by { |tag| tag.public_send(topic_count_column) }.reverse
end
@tags = tags
end
end)
end
2.) Even better: ordering tags per a specified order of tag groups.
Searching around turns up a number of topics requesting more control over tag order, as it often matters for various reasons (genus → species, make → model, etc.) – but responses suggest it would be a fair bit of work.