The discussion revolves around categories missing from /categories.json despite existing in the system, affecting a custom Discourse theme that relies on this API endpoint to display categories on the homepage. Steve_John notes that certain categories, though visible and properly configured, are absent from the API response, even when no topics exist in them. pfaffman suggests the /latest endpoint may exclude categories without topics, but JammyDodger confirms that empty categories should still appear in /categories.json. Steve_John later finds that enabling lazy load resolves the issue, implying the categories were being filtered due to internal logic, though the root cause remains unclear. pfaffman speculates that lazy load may be responsible for omitting categories deemed unnecessary, and suggests hardcoding or using theme settings as alternatives.
{“content”: "יצרנו תבנית מותאמת אישית ל-Discourse שבה קטגוריות ספציפיות מופיעות בדף הבית באמצעות JavaScript. הסקריפט משתמש ברשימת שמות קטגוריות מוגדרת מראש (בתור מערך מופרד בפסיקים) כדי למשוך ולוגם תוכן מ-/categories.json.
בעוד שרוב הקטגוריות מוצגות כראוי, כמה מהן חסרות בדף הבית — למרות שהן מצוינות במפורש בסקריפט וקיימות במערכת עם מזהי קטגוריה תקפים.
בבדיקת תגובת /categories.json, מצאנו שכאלו קטגוריות מסוימות אינן כלולות כלל בפלט ה-API. עם זאת, הן:
קיימות במערכת Discourse
הן קטגוריות ברמת העליונה
יש להן את ההרשאות everyone עם לפחות “See”
אינן בארכיון, מוסתרות או מקננות
אנחנו מנסים להבין:
בתנאים מתי Discourse מחריג קטגוריות מ-categories.json?
כיצד נוכל להבטיח שכל הקטגוריות הנדרשות יופיעו בתגובה זו, במיוחד אם נרצה להציג אותן בדף הבית באמצעות קוד מותאם?
this is on latest discourse version and it doesn’t have any topics yet…I tried to create one dummy topic to one of the invisible category based on category ID , presuming it will invoke the categories json to list them but didn’t help & hence deleted the dummy topic as well..currently both categories has any topics…
Sounds like I’m right. It would be silly to have latest send a bunch of categories that are not used on the outage. I think what I would do is either hard code the categories you want or put them in a theme setting.
You could also make an Ajax call, but that would slow things down.
Right. I think if you get that endpoint it’ll have an categories but that the categories included in /latest are probably only those needed for those topics.
I’ve probably got confused. I thought it was about the /categories.json not including certain categories for an unknown reason and thought I’d try and rule out ones with no topics being the cause.
תודה Pfaffman, JammyDodger. מכיוון שאנו משתמשים בתבנית מותאמת אישית, ניסינו להוסיף כמה קטגוריות שנחסמו בעבר לדף הבית על ידי הוספתן לרשימה הקיימת של הקטגוריות הנחשפות אצלנו ב-JavaScript. כבר יש לנו חמש קטגוריות שמופיעות כראוי באמצעות שיטה זו. עם זאת, הוספת שתי הקטגוריות הנוספות אינה גורמת להן להופיע בדף הבית. כדי לבצע אבחון, אפילו ניסינו לפרסם נושא באחת מהן כדי לבדוק אם זה יפעיל את הראות, אך זה לא השפיע.
הפעלת טעינה עצלית, פתרה את הבעיה להציג את הקטגוריות שלא היו מוכרות קודם..אני לא בטוח איך זה קשור…עם זאת, זה מרמז שבקטגוריות אין בעיית הרשאה..עדיין לא מצאתי את הסיבה השורשית לפתרון בעיה זו.