DNNCommunity / Dnn.CommunityForums

Open-source forums module for DNN Platform. This is a fork and continuance of the Active Forums module.
https://dnncommunity.org
Other
13 stars 21 forks source link

Change Templates to Cached File based #93

Closed Timo-Breumelhof closed 1 year ago

Timo-Breumelhof commented 3 years ago

Is your feature request related to a problem?

Please describe. Editing and testing Forum Templates is cumbersome because the templates are in the database. File based templates would make creating templates much easier.

The reason I think templates should be file based are the following:

Creating a template for the module is a real pain ATM. The module gets the default templates from file (“ActiveForums\config\templates”) When you create a custom template these are stored mainly partly in the database and partly in “ActiveForums\themes”. (where there's also a Module.css which we should get rid of IMO as it has way too specific CSS) For editing you need to go into the edit screen in the module and edit your ascx there, and many time you need to restart DNN for your change to be picked up.

I started creating a Bootstrap 4 template for dnncommunity.org a long time ago and it took me at least 3 to 4 times as long due to constantly having to restart the DNN and the cumbersome edit interface for templates. And then when I wanted to move them from my local machine to the live site, I had to copy them one by one into the edit screen and also save some separate txt file to be able to put them in versioning somehow. Not very good for my motivation ATT if I'm honest, way too many hoops to jump through...

File based templates from a single folder (so there's not some random CSS you need to overwrite) would make the creation of Templates way more efficient and also fun TBH. :-)

Also, some people asked for these templates and they are currently much more difficult to share compared to a simple file based approach. See: https://github.com/DNNCommunity/Dnn.CommunityForums/issues/92

I think we could offer 3 possible locations:

For the default templates that come with the module:

We should however add a note to these templates that they should not be edited.? (overwrite on upgrade)

Describe the solution you'd like

Load the templates (*.ascx) form a "templatename" folder.

WillStrohl commented 3 years ago

I was just about to do this... :D

Timo-Breumelhof commented 2 years ago

I just did a bit more research and the module is using file based cached templates when you select the "default" templates. See: https://github.com/DNNCommunity/Dnn.CommunityForums/wiki/Templates Custom templates are in the Database.

So what we could do is not store them in the database but in the Themes folder. That is a bit less flexible, but it's way easier to manage and also add alternative templates to the module. But I do think we need some kind of debug mode in the module too as clearing the DNN cache for every template change kind of sucks..

WillStrohl commented 2 years ago

I agree that the file-based approach would be better, as it's what nearly anyone would expect anyway.

johnhenley commented 1 year ago

But I do think we need some kind of debug mode in the module too as clearing the DNN cache for every template change kind of sucks..

Perhaps cache settings for the module are ignored? I created an issue to review module cache settings.

WillStrohl commented 1 year ago

Related Issue, should this issue get worked on, it should also keep in mind Issue #97.

johnhenley commented 1 year ago

Questions for the community. Please comment if you have an opinion.

Timo-Breumelhof commented 1 year ago

@johnhenley @WillStrohl Thinking about Templates and themes.. Sorry if I'm making it more complex, just brainstorming :-) At the moment "a theme" that's a bit vague in the module, but I see two approaches.

A. A Theme is a collection of files that makes up the layout of the forum, including template files, css etc. So no real separation between "a template" and "a theme" any more. This is how most modules handle this. A custom theme would be a copy of a theme folder with changes css etc.

B. This post https://github.com/DNNCommunity/Dnn.CommunityForums/issues/170#issuecomment-1341005168 made me wonder. I think most users will not create a complete theme as in option A. (although some will). What if we allow an admin to create an extra style-sheet will load if it exists instead of the default style sheet of the Theme? In that case a folder contains a template and in that folder there's a folder themes, with color variants for instance. We deliver the default.css, Theme with our template and if you copy and edit that file you can use your own stylesheet instead of the default one.

In that case the folder structure could be: /portals/_default/activeforums_themes/bootstrap4/ > contains all needed for a theme including templates and the base css, it also contains a theme.css /portals/_default/activeforums_themes/bootstrap4/custom > If a user places a css file in here that will be loaded instead of theme.css So the css in custom (which we could also name differently of course) is more about colors etc.

So any customization that are only CSS can de done while still getting the updates we apply to the templates etc. and we don't have to guarantee that the default theme will never change. A user that wants a forum in another framework can copy the whole folder rename it and that folder we will obviously not touch on upgrade..

What do you think?

WillStrohl commented 1 year ago

I'm okay with the approach outlined in option B. This allows for minor and major overhauls of the look and feel of the module.

johnhenley commented 1 year ago

For option B, should ~/portals/_default/activeforums_themes/bootstrap4/custom/theme.css REPLACE or ADD to parent ~/portals/_default/activeforums_themes/bootstrap4/theme.css


From: Timo Breumelhof @.> Sent: Wednesday, December 7, 2022 11:44:13 AM To: DNNCommunity/Dnn.CommunityForums @.> Cc: John Henley @.>; Mention @.> Subject: Re: [DNNCommunity/Dnn.CommunityForums] Change Templates to Cached File based (#93)

@johnhenleyhttps://github.com/johnhenley @WillStrohlhttps://github.com/WillStrohl Thinking about Templates and themes.. Sorry if I'm making it more complex, just brainstorming :-) At the moment "a theme" that's a bit vague in the module, but I see two approaches.

A. A Theme is a collection of files that makes up the layout of the forum, including template files, css etc. So no real separation between "a template" and "a theme" any more. This is how most modules handle this. A custom theme would be a copy of a theme folder with changes css etc.

B. This post #170 (comment)https://github.com/DNNCommunity/Dnn.CommunityForums/issues/170#issuecomment-1341005168 made me wonder. I think most users will not create a complete theme as in option A. (although some will). What if we allow an admin to create an extra style-sheet will load if it exists instead of the default style sheet of the Theme? In that case a folder contains a template and in that folder there's a folder themes, with color variants for instance. We deliver the default.css, Theme with our template and if you copy and edit that file you can use your own stylesheet instead of the default one.

In that case the folder structure could be: /portals/_default/activeforums_themes/bootstrap4/ > contains all needed for a theme including templates and the base css, it also contains a theme.css /portals/_default/activeforums_themes/bootstrap4/custom > If a user places a css file in here that will be loaded instead of theme.css So the css in custom (which we could also name differently of course) is more about colors etc.

So any customization that are only CSS can de done while still getting the updates we apply to the templates etc. and we don't have to guarantee that the default theme will never change. A user that wants a forum in another framework can copy the whole folder rename it and that folder we will obviously not touch on upgrade..

What do you think?

- Reply to this email directly, view it on GitHubhttps://github.com/DNNCommunity/Dnn.CommunityForums/issues/93#issuecomment-1341257629, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACI4JZQBPIBPJTBZZMWK3ULWMC5F3ANCNFSM5EFRSUJA. You are receiving this because you were mentioned.Message ID: @.***>

WillStrohl commented 1 year ago

That's a good question... I think we'd want to replace, but I'll defer to @Timo-Breumelhof on this one.

Timo-Breumelhof commented 1 year ago

@johnhenley @WillStrohl Yes good question :-)

Difficult to answer..

We are providing this option for the use case that someone wants to create a color variation of a template. I think that if you would want to change a lot, also layout, you'll probably copy the folder and create your own template.

I'm not a fan of overwriting existing values with a custom style sheet TBH. (which would rule against adding) But it can also get cumbersome if ~/portals/_default/activeforums_themes/bootstrap4/theme.css would change (not the colors something in the layout) and you would have to incorporate that into your in ~/portals/_default/activeforums_themes/bootstrap4/custom/theme.css

I think ADD is better. This will be used for relatively small changes and it's less prone to issues when the main template would have any CSS updates.

What do you think? @WillStrohl @johnhenley

Timo-Breumelhof commented 1 year ago

FYI, I edited my previous comment

WillStrohl commented 1 year ago

I agree with that, Timo... That sounds like a less annoying experience for designers, and we should always look at these updates in a way that also incorporates the way people will feel when interacting with these updates later. That will directly impact overall long-term adoption and usage.

johnhenley commented 1 year ago

I think ADD is better.

I agree it should be ADD so that you're not duplicating the base theme.css file in your custom version. You're only customizing the things need to override.