Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File-based templates #57

Open
toonvandeputte opened this issue Oct 21, 2015 · 3 comments
Open

File-based templates #57

toonvandeputte opened this issue Oct 21, 2015 · 3 comments

Comments

@toonvandeputte
Copy link

I've forked wp-polls and am working on a file-based templating system (in addition to the wp_option based system). You can check the current state of my version at: https://github.com/klassebe/wp-polls
Its current state is usable for my particular situation, but I will improve upon it. I'm also looking for other people's input or thoughts on a feature like this.

The main reason for doing this is to enable poll styling to be done within a theme's folder, instead of only via wp-admin. I've tried to take a backwards-compatible approach, so file-based templating can be easily integrated if that would ever be an option, without breaking lots of people's existing setups.

Also, I think the default templates are rather lacking. They have a lot of inline styles, and few classes to enable custom styling. So I find myself needing custom templates most of the time.

How it works:

  • A theme creator can create a 'wp-polls' folder in their theme folder, and populate it with template files. These are simple html files, named according to the option names that are used for the different templates by the plugin.
  • Upon activation, the plugin checks whether template files are present in a /wp-polls directory within the current theme's stylesheet directory (so that means child themes need to have their own templates)
  • For each individual template, if it is present in the theme's 'wp-polls' folder, the contents of the html file is saved as the value for that template's corresponding option.
  • When a theme creator adds or modifies files in the theme's 'wp-polls' folder, they need to update the option values for the templates via the plugin's template screen in wp-admin. Users can also reset the templates to their default version. Each template option now has two 'reset' buttons, one for the plugin's version of the template, and one for the theme's version. The second button is not visible if the needed file does not exist.

Proposed modifications/additions:

  • Provide a global templating option (toggle) to either use wp-polls' own templates, or the theme's templates
  • Better parent/child theme support
  • Move wp-polls' own templates to individual html files, which can be copied to a theme's folder by theme creators
@lesterchan
Copy link
Owner

I like that idea! But it seems to be a huge change! Probably need to get it tested really well.

@toonvandeputte
Copy link
Author

Thanks for the encouragement, I'll try to develop it further and get it as simple, straightforward and backwards-compatible as possible.

@espellcaste
Copy link

Also liked the improvements. Count me in for testing! Never really liked the inlined codes in the template as well. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants