The discussion revolves around accessing the full description of a category in a Discourse theme. sbernhard wants to add custom links near the “top” and “Latest” buttons in a category, and thought of storing the link data in the “hidden part” of the category description. However, they discovered that category.description and category.description_text only return the first paragraph of the description.
Falco confirmed that this is the expected behavior and suggested making an extra API call to retrieve the full content. Falco also shared an example of a theme component that does exactly this.
Johani proposed an alternative approach using a setting with a target category and link details, and then using the customFilter method to conditionally render the links. However, sbernhard found this approach not feasible due to the large number of categories.
With Falco’s guidance, sbernhard was able to create a theme component that achieves the desired functionality. The theme component, discourse-add-category-links, is now available for use.
AFAIK, the description is stored (and maintained) in the first section of the first post in a description.
I want to add links near “top”, “Latest” buttons in the category. As a theme can not be configured for each category, I though I can simply add the data for the links in the “hidden part” of a category description - as only the first fragment of the category description is shown in the category list.
The data would look like this {TAG,linkText,linkTitle,linkHref}.
category.description returns the well formed category description
category.description_text returns the plain data
but both are just returning the first chapter of the description and not the complete first post of the category which contains the description. Do I miss something?
Thanks @Johani. I thought about your suggestion. Unfortunately, we have a huge amount of categories and the configuration in the settings would be large and not manageable. Therefore I wrote this theme.
I got it working right. After adding support for parent_categories and fixes some minor glitches, I will document it and “release it in a proper way”.