Hi everyone, I’m getting started on developing things for Discourse, and I’m working on a theme component.
Link: GitHub - NateDhaliwal/discourse-persistent-banner: A theme component for Discourse that cannot be closed by the user. · GitHub
When putting it on Theme Creator, the settings don’t appear, even though I have a settings.yml. Any ideas?
Moin
9월 20, 2024, 8:28오전
2
Do you see any error messages at theme creator?
I think you have to use the same quotation marks at the beginning and end.
This could also be a problem. I would try default: ""
Maybe you want to add “block” to the choices. Otherwise you have to use the revert button to choose that again.
Whoops, just realised I was clicking on ‘Create new’ instead of importing it…
But now, when I try using the URL, it says that about.json is invalid or doesn’t exist, asking me if it is a theme.
About.json:
{
"name": "Persistent banner",
"about_url": "https://meta.discourse.org/t/discourse-persistent-banner/330575",
"license_url": "https://github.com/NateDhaliwal/discourse-persistent-banner/blob/main/LICENSE",
"component": true,
"theme_version": "5.0.0",
"authors": "NateDhaliwal"
}
Is there something wrong?
Missing comma after license URL.
@merefield Would version be in ""?
Probably that too. Just look at examples.
Thanks! One last one, I can’t seem to get the variable to display.
https://github.com/NateDhaliwal/discourse-persistent-banner/blob/main/common/header.html
Was it because I didn’t initialise it properly? I tried following the guide…
Would I have to use
import Component from "@glimmer/component";
export default class PracticeComponent extends Component {
get bannerLinks() {
return JSON.parse(settings.banner_links);
}
}
then?
Look at the billions of examples
You only need to use a gjs file if you need to process stuff with javascript, otherwise an hbs template file might suffice. Experiment.
I’m not sure if I’m going in the right direction.
I made javascripts/persistent-banner.hbs with this:
https://github.com/NateDhaliwal/discourse-persistent-banner/blob/main/javascripts/persistent-banner.hbs
But nothing shows up. Tried putting it in different places, still won’t work.
Tried looking at example, but many don’t seem to help.
Any advice?
Moin
9월 21, 2024, 11:51오전
13
어떤 플러그인 아웃렛에 배너를 배치하시겠습니까?
Using Plugin Outlet Connectors from a Theme or Plugin 를 참고해 보세요.
https://meta.discourse.org/t/add-a-featured-topic-list-to-your-discourse-homepage/132949?u=moin 을 예시로 사용할 수 있습니다.
플러그인 아웃렛의 이름과 위치를 확인하려면 (deprecated) Plugin outlet locations theme component 을 사용할 수 있습니다. 예를 들어 "above-main-container"는 사이드바 위가 아닌, 주제 목록 바로 위의 가장 상단 영역을 가리킵니다.
비슷한 기능을 추가하는 #customization:theme-component의 코드를 살펴보는 것도 배우는 데 매우 좋은 방법입니다.
You do not need and should not put script tags in hbs files. They should be limited to the content of the template.
Don’t stab in the dark, read the guides:
There's a new component API in Octane! For this section, we'll be focusing on the differences between the new style, known as Glimmer components, and classic components, and how to upgrade. "Classic" components refer to older-style components that do...
So… I managed to get it working without using a hbs file, but instead using the <script> tag with handlebars, and it now works.
I use it like this for now, but I’ll continue to try using a hbs file instead.
Lilly
(Lillian )
9월 22, 2024, 3:24오전
16
created a quick pull request for you so you can see the way to split up the files properly. feel free to merge or just have a look at the branch .
https://github.com/NateDhaliwal/discourse-persistent-banner/pull/3
Thanks so much! It works now!
Lilly
(Lillian )
9월 22, 2024, 3:15오후
18
No worries Nate. Keep up the experimenting, reading and looking at other examples. In no time you’ll be much better than I am at this dev stuff
Thanks for the encouragement!