XF 2.3 Addon themes, Page config,

Liam C.

Member
Hi there, I am developing an addon and would like thoughts on two features I have planned but would like thoughts on the best way to implement it / if it is a bad idea to implement it.

Addon Themes: This would be themes provided by the addon itself, rather than Xenforo themes. Meaning that I could create Light and Dark theme regardless if the site has a theme or not. I am using my own customer page_container. We have plans to make around 8 custom themes with this in mind.

Config outside of Admin Control Panel: I am currently considering editing the config on a config route (for e.g. /addon-name/config), this would make for custom elements to easily be made (for e.g. we plan to have an "Add Source" button to add for an element, as there'll be a forEach function for each source for specific functions)

If anyone has suggestions on how to do an "Add Source" button within the Admin Control Panel, that would also be good!!

Looking forward to replies! Thank you!!
 
Last edited:
The bigger picture of what you're trying to accomplish isn't clear to me. The canonical way of providing different styles is independent from add-ons. If you want your add-on appearance to be configurable, you can likely create style properties to achieve this.

Adding routes and pages the control panel is largely the same as adding them to the public app, it's all just routes, controllers, and templates at the end of the day.
 
The addon, in it's simplest form, is a panel. The idea is that they can click a bunch of styles (for e.g. "Extreme Dark", "Light Dark", "Light", "Light Red theme").

However when the user visits normal pages, these will not affect our current page. My current thoughts is to save it to their localStorage and have the addon read it, and add that class to the p-body to then change the style via CSS. My question was to ask if there is any other suggested method, for e.g. I considered creating a child style but the issue with that is that only certain users will have access to this panel.


In regards to the control panel, I'm glad to hear that. I've only been using options so far, so this is a relief to see. Thank you. I'll look into how to do that later today.
 
Yeah, swapping the CSS classes on a condition is likely the way to go. You can store the preference wherever makes the most sense to you, though because local storage is invisible to the server the preference would only be applied after the page has loaded. A cookie or even a database column would make it possible to apply the condition via SSR while still allowing swapping via JS without a reload. That's basically what we do for the color scheme preference.
 
Back
Top Bottom