NodeBB / NodeBB

Node.js based forum software built for the modern web
https://nodebb.org
GNU General Public License v3.0
14.21k stars 2.8k forks source link

Possible to have widget areas defined entirely in template files? #1387

Closed julianlam closed 10 years ago

julianlam commented 10 years ago

Just a question for @psychobunny, would it be possible for widget areas to be defined entirely in a theme's template files?

Seems the minimum required is this js:

{
    'name': 'Homepage Content',
    'template': 'home.tpl',
    'location': 'content'
}

and this html:

<div widget-area="content" class="hidden"></div>

Could it be reduced to:

<div widget-area-id="content" widget-area-name="Homepage Content">. with the template argument inferred from the template file itself?


The reason why I bring this up is because creating child themes doesn't bring the widget areas over, so it's impossible for me to have a child theme with my own widget areas and inherit the widget areas already present in vanilla.

You might think "but vanilla's templates can be overwritten by template files in your theme", which is exactly why we'd detect widget areas on load, thus getting a proper set of widget areas based on which ones are actually present in the template files.

I imagine using something like grep to look for the widget codes during NodeBB startup (in compileTemplates) might be it.

psychobunny commented 10 years ago

Yes the last part is key. Since when did you start writing essays for issues? owait :D

julianlam commented 10 years ago

haha alright :+1: -- the sooner you do it the better, afaik nobody uses widget areas in themes except us, so we can deprecate it without notice.

psychobunny commented 10 years ago

The challenging part is pulling widget info out of the templates

psychobunny commented 10 years ago

The reason why I bring this up is because creating child themes doesn't bring the widget areas over

Equal issue for JS files being brought over to child theme (ex. imagine Vanilla included a bunch of JS files for modifying stuff - Lavender as a child theme would require all those JS files too).

So if this is your primary concern this issue should be refiled as something higher up (ex. "Child themes should inherit Parent theme's plugin.json IF none is specified").

Closing this because reading widget area data from tpls isn't practical from what I tried.