Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2015-06-05 11:58:28

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Theme prefs plugin

Bloke wrote #291348:

Are we talking about non-admin users here? i.e. not Designers, but Staff Writers? Because anyone else has access to the Presentation panels anyway so they can alter any tags you may have set up — either via <txp:variable> or a (currently fictional) tag for setting prefs in this plugin?

What I want is to make it really simple (for everybody) to install templates. That’s it. After that, if an admin who know what is doing want to change anything, he is the boss…


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#38 2015-06-05 12:11:16

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: Theme prefs plugin

NicolasGraph wrote #291351:

What I want is to make it really simple (for everybody) to install templates.

Right, ok. So, by ‘Templates’ you mean Pages & Forms? Are you using rah_flat or something like that to design them outside Txp? In which case, having some way to define the prefs that will then appear in the Preferences panel for editing values makes sense. Sort of.

The problem will be that if you rename one or delete one from the template, it’ll still be there in the prefs panel. So then you need to have the notion of a <txp:oui_prefs_delete> tag too? Which you only run once, then have to go and delete from your template. And if you have all the prefs defined in a Form, for example, using this plugin’s fictional ‘add’ tag, you need to include that Form in your design somehow with a <txp:output_form /> tag in order to make it do anything. That adds processing time / weight to your Pages and is also unnecessary: after all, once the vars are set, you don’t need to keep adding them every page load. You only need them to be read back from prefs.

Seems like we’re approaching this in the wrong way, which is why I wondered if having the vars defined in a sort of ini file that the plugin reads (only when visiting the admin side) you could then:

  1. Manage the available vars externally (not sure about deletions / alterations: ideas welcome).
  2. Not have to worry about difficulties upgrading the plugin in future.
  3. Give users the ability to edit the pref values from the UI, and control access rights based on their login type.
  4. Not have to add any unnecessary tags to your templates.

But it all depends on your workflow and what’s easiest for you. etc_variables sounds like a good fit.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#39 2015-06-05 13:27:33

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Theme prefs plugin

Bloke wrote #291352:

Right, ok. So, by ‘Templates’ you mean Pages & Forms? Are you using rah_flat or something like that to design them outside Txp? In which case, having some way to define the prefs that will then appear in the Preferences panel for editing values makes sense. Sort of.

Yes that’s what I try to achieve. See my first post:

NicolasGraph wrote #291290:

Hi,
I’m trying to set a plugin to easily manage themes prefs from the Txp advanced prefs page.
I used to use adi_variables in the past, but I’m playing with rah_flat now, which is not compatible with.
As Jukka suggested in this Github post I’m trying to add the prefs managed with adi_variables though new prefs fields.

In fact I’m looking for something like a new adi_variables to use with rah_flat but, on my side, I don’t need (maybe other Txp users need it) a user interface to define the prefs / variables names; I only need it for values.

Bloke wrote #291352:

The problem will be that if you rename one or delete one from the template, it’ll still be there in the prefs panel. So then you need to have the notion of a <txp:oui_prefs_delete> tag too? Which you only run once, then have to go and delete from your template. And if you have all the prefs defined in a Form, for example, using this plugin’s fictional ‘add’ tag, you need to include that Form in your design somehow with a <txp:output_form /> tag in order to make it do anything. That adds processing time / weight to your Pages and is also unnecessary: after all, once the vars are set, you don’t need to keep adding them every page load. You only need them to be read back from prefs.

Seems like we’re approaching this in the wrong way, which is why I wondered if having the vars defined in a sort of ini file that the plugin reads (only when visiting the admin side) you could then:

  1. Manage the available vars externally (not sure about deletions / alterations: ideas welcome).
  2. Not have to worry about difficulties upgrading the plugin in future.
  3. Give users the ability to edit the pref values from the UI, and control access rights based on their login type.
  4. Not have to add any unnecessary tags to your templates.

But it all depends on your workflow and what’s easiest for you. etc_variables sounds like a good fit.

Ok, I understand. Plugin dev is a real job…
etc_variables looks fine but, if I understand well, I can’t embed the prefs needed to make my templates work. They have to be created by the admin, right?

Last edited by NicolasGraph (2015-06-05 13:28:53)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#40 2015-06-05 13:39:49

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: Theme prefs plugin

NicolasGraph wrote #291353:

I don’t need a user interface to define the prefs / variables names; I only need it for values.

Makes perfect sense if working with rah_flat. There’ll be a solution somehow. Willing to accept ideas from anyone at this stage on the best approach.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#41 2015-06-05 13:47:04

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Theme prefs plugin

Could it become a part of rah_flat?
Could it be possible to add prefs like sections? It would be perfect but I really don’t know if it’s possible and how…

Edited to add the link

Last edited by NicolasGraph (2015-06-05 13:49:04)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#42 2015-06-05 14:03:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: Theme prefs plugin

NicolasGraph wrote #291355:

Could it be possible to add prefs like sections?

Sure, that’s easy. JSON is a good choice as it’s fairly readable and easy to parse. Just got to decide where the file should live in the directory structure. Suppose a pref would be the way to go, with some sensible default.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#43 2015-06-05 15:34:19

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,743
Website

Re: Theme prefs plugin

Wow, things have moved fast here and a few plugins have come up that I haven’t seen before. Must read more carefully later, but …

Regarding setting prefs in your own flat files, did you see that rah_flat already supports that? As far as I can tell (not having tried it), it prefixes its prefs with rah_flat… so won’t bork other prefs (but try it first!!).

I don’t think rah_flat downloads anything at all from the db into flat files, so it won’t respect changes you make via the admin panel (if you are indeed allowed to). That also kind of goes against the idea of managing things via flat files and was the root of the problem with adi_variables.

Thinking aloud (but hazy, coz it’s 30° here on a Friday afternoon), the other way you might be able to set up your prefs once and then allow them to be user-editable is to either use a small setup script for your site, that you then switch off (I do that to quickly update prefs for local, staging and live dbs), or use a plugin by net carver, the name of which I forget, which allows you to set up a start configuration.


TXP Builders – finely-crafted code, design and txp

Offline

#44 2015-06-05 15:48:00

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: Theme prefs plugin

jakob wrote #291359:

[…] or use a plugin by net carver, the name of which I forget, which allows you to set up a start configuration.

Was it sed_cleaner?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#45 2015-06-05 16:15:48

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,743
Website

Re: Theme prefs plugin

Yep, that was it…


TXP Builders – finely-crafted code, design and txp

Offline

#46 2015-06-05 16:30:50

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Theme prefs plugin

uli wrote #291361:

Was it sed_cleaner?

It looks great, didn’t know about it… i’ll test it next week.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#47 2015-06-07 13:01:10

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Theme prefs plugin

Bloke wrote #291356:

Sure, that’s easy. JSON is a good choice as it’s fairly readable and easy to parse. Just got to decide where the file should live in the directory structure. Suppose a pref would be the way to go, with some sensible default.

jakob wrote #291359:

Wow, things have moved fast here and a few plugins have come up that I haven’t seen before. Must read more carefully later, but …

Regarding setting prefs in your own flat files, did you see that rah_flat already supports that? As far as I can tell (not having tried it), it prefixes its prefs with rah_flat… so won’t bork other prefs (but try it first!!).

I don’t think rah_flat downloads anything at all from the db into flat files, so it won’t respect changes you make via the admin panel (if you are indeed allowed to). That also kind of goes against the idea of managing things via flat files and was the root of the problem with adi_variables.

Thinking aloud (but hazy, coz it’s 30° here on a Friday afternoon), the other way you might be able to set up your prefs once and then allow them to be user-editable is to either use a small setup script for your site, that you then switch off (I do that to quickly update prefs for local, staging and live dbs), or use a plugin by net carver, the name of which I forget, which allows you to set up a start configuration.

I don’t know how is it possible or not to add prefs with editable values via JSON but it seems that rah_flat can only alter the values of existing prefs for now. And if I understand well it’s the same for sed_cleaner (but I like the way you can import plugins with this one, I would like to see this feature in rah_flat).

I don’t think that editing prefs values via the Txp interface goes against the idea of managing flat files when these prefs are dedicated to users. As a designer I need to define UI prefs and I could do it via flat files but the user, on his side, needs an interface to edit their values.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#48 2015-06-09 08:40:00

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Theme prefs plugin

Well, this is my new workflow to easily install a theme with custom prefs:

!!For new install only; do not use sed_cleaner on existing websites as it removes your content!!

  1. Paste the Txp folders on my host;
  2. paste my rah_flat templates folders (but I could skip this step and use sed_cleaner to install my templates) ;
  3. paste my custom files folder containing the required plugins (included a custom oui_prefs and rah_flat) with the .plugin extension for sed_cleaner (thanks to pointing this out);
  4. install Txp;
  5. install and enable sed_cleaner;
  6. all done!

Here is the sense of oui_prefs I think; of course I have to edit it for once during the design process, but after that, the whole install is just a pasting and enabling work.
Even easy enough to be done by anyone and could be used for theme distributing (?), just need to join the custom oui_prefs plugin to your templates (pages, forms, etc.).
Does it makes enough sense to see it released?

Edited for typos

Last edited by NicolasGraph (2015-06-09 16:35:13)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

Board footer

Powered by FluxBB