Is it possible to add a custom field to tags using the same logic?
Has anyone applied this to groups? If so, can you share what you did?
I guess this would do the trick. Hopefully itās still up-to-date.
No, tags donāt have custom fields. What are you trying to accomplish?
Yes, that repository should work. Just change all instances of my_field
to the name of your field.
I am trying to create the following plugin: Creating a User - Tag relation plugin
Is there some more documentation about how to customize these group fields? It works indeed great with this boilerplate code. But how to extend it properly?
I for example want to add a few input fields, like:
<div class="control-group">
<label class="control-label" for="map">Chapter coordinates</label>
<input name="chapter_coordinates" id="chapter_coordinates" class="ember-text-field ember-view input-xlarge" value={{group.custom_fields.group_coordinates}} placeholder="E.g. 52.3727598,4.8936041" type="text">
<div class="control-instructions">Fetch coordinates from https://nominatim.openstreetmap.org/</div>
</div>
But Iām just guessing what to do here and then add the rest of the Discourse stuff. The example above is to use a field for coordinates. I intent to use the g.json
to create a map based on the group metadata.
I also intend to add a checkbox for emailing the group with a mail setup for that group.
<div class="control-group">
<label class="control-label" for="map">Contact chapter by email</label>
{{input type="checkbox" checked=group.custom_fields.contact_group_by_email}}
<span>{{i18n 'admin.groups.contact_group_by_email.label'}}</span>
</div>
However, this field is best placed in the interaction tab. How to know what to do to get it there? I would like to become more proficient with this. But I get the idea that this information is just in the code, not documented somewhere. Which is probably fine, but just takes more time and effort to find what Iām looking for. Although what I want to add is quite small, just a few fields to the groups
Yes, it can be tricky and a bit overwhelming when starting to navigate the Discourse codebase. It sounds like youāre trying to work with GeoJSON. Have you considered using or extending the Locations Plugin? Thatās already set up to work with GeoJSON in Discourse.
A course in plugin development?
Iāve been considering running a free course in discourse plugin development, which is essentially what you need. Iāve already written the course materials for a course in theme development (see below). If 30 people vote for one in plugin development Iāll write a give a course (via zoom) in it.
- Write and give course in plugin development
- Donāt write and give a course in plugin development
Introduction to theme development
- GitHub - pavilionedu/discourse-theme-introduction
- GitHub - pavilionedu/discourse-theme-css
- GitHub - pavilionedu/discourse-theme-colors
- GitHub - pavilionedu/discourse-theme-html-one
- GitHub - pavilionedu/discourse-theme-html-two
- GitHub - pavilionedu/discourse-theme-javascript-one
- GitHub - pavilionedu/discourse-theme-javascript-two
*ps if it hits 30 please let me know.
Awesome! I actually will use a fork of this Fairphone community map. They use the raw YAML output of a topic. Iāve modified my fork to use the data from g.json to draw markers on the map. I just miss a few fields such as coordinates and a boolean to use an email address in the map. Maybe some more, but first Iāll need to know how things work. Thanks for the links! Will have a look this week and see how far Iāll get. A course would be awesome too! My JS/Ruby skills are now though. Mainly Python/Bash and some crumbs from other languageās.
Is it possible to add custom fields to posts? Ideally from the post composer.
What is the minimum discourse version required to use this plugin?
(discourse-topic-custom-fields)
Is this GitHub - pavilionedu/discourse-group-custom-fields still up to date?
The reason I ask is because I attempted to implement a new custom group field, but it doesnāt seem to be saving/persisting the value I enter into the input field after clicking Save.
Hereās the commit with all of the changes I did that (I think) correctly followed the edu repoās structure: add discord_role_id field to groups Ā· aloha-pk/discourse-discord-sync@fd3eef1 Ā· GitHub
Yes, I just tested it and itās working as expected.
{{input type="text" checked=group.custom_fields.discord_role_id}}
Your issue is that youāve changed the input type to text
, but left the value input as checked
. You need to change checked
to value
.
Welp, thatāll do it Thanks for the help!
Was just able to rebuild with this change, but unfortunately am still seeing the same issue. The value I entered gets cleared out after I save and re-load the page.
Any other suggestions @angus?
Did you change anything else from the example? The example works. Try starting with the example itself. If thatās also failing in your environment, then something else is going on. If the example works in your environment, then progressively work through the changes you made until you find the one thatās breaking it.
Hi @angus added a custom filed using this plugin and it is working fine now how can i show this filed on category page below category name
Hereās how you can figure that out:
-
Find the templates in discourse/discourse that render the category page (search for a html element on the page)
-
Find a plugin-outlet in one of those templates
-
Use the plugin outlet as described here
written this code but it is still not working can you tell the issue
<script type="text/discourse-plugin" version="0.8">
const { getOwner } = require("discourse-common/lib/get-owner");
const { htmlSafe } = require("@ember/string");
api.decorateWidget("category-heading:after", (helper) => {
const category = helper.attrs.category;
if (category.custom_fields?.location) {
const customLocation = htmlSafe(category.custom_fields.location);
const template = getOwner(helper).lookup("template:components/category-header");
return template.fragment.build("custom-location", { customLocation });
}
});
</script>
<script type="text/x-handlebars" data-template-name="components/category-header/custom-location">
<div class="category-custom-location">{{customLocation}}</div>
</script>
What part of it is not working? For example, what do you see when you stick a console.log(category.custom_fields)
in there?
I installed this plugin today with this code and it appears to be broken: https://github.com/pavilionedu/discourse-category-custom-fields.git
It installs as āEducation Category Custom Fieldā and the author information isnāt there:
What do you expect to happen? Itās not supposed to do anything without modification.