Het zal het probleem oplossen dat ik mijn ondersteunend personeel vertel dat ze eerst een nieuw onderwerp moeten aanmaken, het vervolgens moeten opslaan, dan naar de URL moeten kijken en het ID # moeten ophalen, dan terug moeten gaan en het onderwerp moeten bewerken om de # handmatig in de body te plaatsen.
Waar gaat dat ticket/bug naartoe? De ID staat in de URL; daar is het persistent en nooit fout. Hoe helpt het om de topic ID in de tekst van het topic te hebben? En, zoals u aangeeft, als het in de hoofdtekst van het bericht staat, kan iedereen het veranderen, verwijderen of verkeerd typen.
Gebruikt iets anders de topic ID? Zo ja, wat en hoe?
It will be easier to create a custom component that appends this to the correct posts rather than filling a template.
If you edit the code of your theme under admin > themes & components… and add this to the JS tab, it should get you what you’re after with some adjustment:
import { apiInitializer } from "discourse/lib/api";
import Component from "@glimmer/component";
class TopicIdentifier extends Component {
get topicId() {
return this.args.post?.topic?.id;
}
get shouldShow() {
const firstPost = this.args.post?.post_number === 1; // first post in topic
const desiredCategories = [45, 3]; // a comma separated list of category IDs you want this to appear in
const isInCategory = desiredCategories.includes(
this.args.post?.topic.category.id
);
return firstPost && isInCategory;
}
<template>
{{#if this.shouldShow}}
<!-- you can edit the content below, {{this.topicId}} is where the topic ID will be filled -->
This topic's ID is
{{this.topicId}}
<!-- you can edit the content above -->
{{/if}}
</template>
}
export default apiInitializer((api) => {
api.decorateCookedElement((element, helper) => {
const wrapper = document.createElement("div");
wrapper.className = "custom-topic-id"
helper?.renderGlimmer(
wrapper,
<template><TopicIdentifier @post={{helper.model}} /></template>
);
element.appendChild(wrapper);
});
});
You can find the category ID from its URL to configure desiredCategories, for example, the support category here on Meta has the ID of 6
You can add CSS to style this how you’d like with the CSS tab… for example
They can just type /t/138 and not have to search. But if you are talking to a person, wouldn’t saying "search for bug about “some words they know” make more sense to use in conversation than a number?
And that was going to be my other suggestion.
I think I’d have used renderInOutlet rather than decorateCookedElement, but that’s probably because I don’t fully understand decorateCookedElement.
But this will don’t let you search for a bug/topic by topic_id.
But I want to search. It’s easier.
Go to site, then append /t/id to the URL at the top of the window VS go to site and type ID into the search field that’s right in the center of the page.
If I’m talking to a person, or typing a message, yes a number is more concise and less error prone than “Search for exact title that might be 5 words long”
I will look into that, but if it kills being able to use in a search field, then it won’t work for me.
I really love Discourse, and I have gotten a TON of useful feedback and help from everyone here.
What I don’t understand is that occasionally folks tell me that “You shouldn’t do it that way because this way is better.” Well, no, this way is better for you, but that way is better for me. And neither is wrong.
Yeah don’t bother then, unfortunately it only appends content to the topic when it’s rendered… it doesn’t add it to the database to make it searchable. I think what you’d ultimately need is a custom plugin or a custom script added to Discourse Automation for it to be fully automatic.
Searching by topic ID or including it in a template isn’t a common request, so it’s not something we support out of the box.
I think it’s that regulars here know it’s not a feature we currently have, so we’re trying to support you by figuring out some potential work-arounds.
And often if you go back you can find a better solution.
If you really want to embed them topic id in the text so you can find it in search then you’d need a plugin and it could add ticket123 to the raw text (I think search looks at raw?). The topic id doesn’t exist before you create the topc, so you can’t insert it when you create it.
Oh! Maybe what you want is a plugin that would add a tag bug123 when a topic in a bug category gets created. Then you could refer to it as #bug123 and have it link anywhere you mention it and be able to search. If you’re self hosted or on enterprise that wouldn’t be too hard. I imagine someone in Marketplace would do it for $250 to $500.
Or, if you want to be able to “search” for a bug by number, you could add a theme component that let you type it in a ‘bug box’ and go straight there. Maybe that’s a solution that would work and it wouldn’t require a plugin.
Het resultaat is een meer discrete weergave van de topic-ID. Het is nog steeds niet doorzoekbaar, maar ik kan ermee leven totdat wat ik echt nodig heb werkelijkheid wordt.
Bedoel je topic:124240? Het stopwoord (‘hallo’) was slechts een voorbeeld. In het geval van Tag Banners werkt ‘hoi’. Misschien als je een veelvoorkomend woord hebt in supporttickets, of gewoon een veelvoorkomend woord in het algemeen, kun je dat proberen?
Also, if what you want to do is “search” for a topic id, then you could probably make a component that accepted a topic ID and then just jumped to that topic.