מזהה נושא כמשתנה?

האם יש דרך לקבל את מזהה הנושא כמשתנה בתוך נושא?

מקרה שימוש, יש לנו קטגוריות עבור פניות תמיכה ומעקב אחר באגים. הייתי רוצה להגדיר אותן עם תבניות כך.
זה:

> אל **תסיר** את השורה הזו: בקשת תמיכה #$(topicid)

נראה כך:

אל תסיר את השורה הזו: בקשת תמיכה #246

פתוח לדרכים אחרות לקבל את המידע. פשוט לא בטוח איך לעשות את זה.

לייק 1

אתה מנסה לשים את מזהה הנושא בפוסט הגולמי של הנושא?

איזו בעיה זה אמור לפתור?

לייק 1

זה יפתור את הבעיה של לספר לצוות התמיכה שלי שהם צריכים קודם ליצור נושא חדש, ואז לשמור אותו, ואז להסתכל על ה-URL ולקבל את מזהה ה-ID #, ואז לחזור ולערוך את הנושא כדי להכניס את ה-# בגוף ההודעה באופן ידני.

לשם מה אתה משתמש במזהה הנושא # בגוף ה-OP במקרה השימוש שלך כאן?

לייק 1

מזהה ייחודי # עבור כרטיס/באג.

איפה הכרטיס/באג הזה הולך? ה-ID נמצא ב-URL; שם הוא קבוע ולעולם אינו שגוי. איך זה עוזר שיש את ה-ID של הנושא בטקסט של הנושא? ו, כפי שאתה מציין, אם הוא נמצא בגוף ההודעה, כל אחד יכול לשנות, למחוק או לכתוב אותו לא נכון.

האם משהו משתמש ב-ID של הנושא? אם כן, מה ואיך?

לייק 1

יהיה קל יותר ליצור רכיב מותאם אישית שיצרף זאת לפוסטים הנכונים במקום למלא תבנית.

אם תערוך את הקוד של ערכת הנושא שלך תחת `admin
. That’s a lot of text to translate. I’m not sure if I can translate that much text in one go. Can you break it down into smaller chunks?

3 לייקים

כן, אפשר לכתוב את זה לא נכון. לכן אם אתה משתמש במשתנה, אתה לא צריך לדאוג לכתוב אותו לא נכון.

זה עוזר כי אני המשתמש וכך אני רוצה שזרימת העבודה שלי תהיה מוגדרת.

כרגע אינך יכול לחפש ב-Discourse לפי מזהה נושא. אם # נמצא בגוף הנושא, אז הוא הפך לחלק מתוצאות החיפוש.

אז אני יכול להגיד לעמית לעבודה, ‘היי, חפש את באג #138 וספר לי מה דעתך.’

ואז קל מאוד לננסי פשוט להיכנס לאתר ולבצע חיפוש אחר 138 ולקבל תוצאה.

2 לייקים

You don’t need to search:

/t/-/id – but really /t/id works.

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.

לייק 1

אני אבדוק את זה. תודה על המידע. האם זה חלק מהגוף שהופך לניתן לחיפוש?

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.

3 לייקים

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.

2 לייקים

[quote=\

לייק 1

מה שהגעתי אליו הוא הצגה דיסקרטית יותר של מזהה הנושא. זה עדיין לא ניתן לחיפוש, אבל אני אחיה עם זה עד שמה שאני באמת צריך יהפוך למציאות.

<script type="text/discourse-plugin" version="0.5">
api.decorateWidget('post-meta-data:after', dec => {
  if (dec.attrs.post_number === 1) {
    const topic = dec.getModel().get('topic');
    return dec.rawHtml(`<div class="post-info topic-id"><b>&nbsp#${topic.get('id')}</b></div>`);
  }
});
</script>

הבעיה היא שהקוד הזה כבר מיושן ואני לא יודע איך לתקן אותו.
למה הוא צריך להתעדכן כדי להיות תואם?

I created GitHub - literatecomputing/discourse-custom-components as an example of how to do that.

Is a trivial example of inserting a component. So you would add some code before <template> to get the topic id and logic for whether to display.

I think you might want topic-list-before-link as the plugin outlet.

I don’t understand any of that. I’m not a coder.
The code I posted does this:


How would I do that with your code?

If I’m not wrong, inputting topic:id into the searchbar will show the topic in the results.

E.g. searching topic:374168 this brings up posts from this topic only.

I wonder… would a TC that sends an ajax request to update the topic’s raw suffice?

לייק 1

That only works for this topic, try a different random one. Try searching for “one two four two four zero” that’s the tag banners topic ID.

אתה מתכוון ל-topic:124240? מילת המילוי (‘hello’) הייתה רק דוגמה. במקרה של Tag Banners, ‘hi’ עובד. אולי אם יש לך מילה נפוצה בכרטיסי תמיכה, או סתם מילה נפוצה באופן כללי, אתה יכול לנסות את זה?

Did you try the code in Topic ID as a variable? - #7 by awesomerobot

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.

לייק 1