Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#73 2018-04-01 22:14:13

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

Re: Theme prefs plugin

On my quest to bring some older plugins that are vital for several of my installations into the 4.7 epoch, this is another candidate, but I’m no longer sure what the state of play is, and therefore what to (try and) work on.

I have some sites with oui_prefs (I think this version) with my own variables defined in the plugin source, and other sites where I have used rah_flat/oui_flat’s pref/variable import capacity in my /templates folder.

  1. There’s mention above in this thread of more advanced versions of oui_prefs (or smd_prefset) that store the definitions for site_variables in a file but I can’t find a more recent download, so I am not sure what I could look at bringing up to scratch.
  2. The urgency in getting smd_prefset out probably got derailed by the advent of oui_flat’s ability to import prefs/variables from the flat file folder. Now that themes have been incorporated into txp 4.7, rah/oui_flat is effectively rendered obsolete. However the new themes mechanism doesn’t include prefs/variables (yet) so this bit of functionality is left unresolved (for my sites at least). It looks similar in principle to how rah_/oui_flat worked, so maybe it already includes a lot of the functionality needed for prefs/variables?

What’s the best way of proceeding?

  • Is it worth going back to oui_prefs/smd_prefset to fill this gap? That would be okay for my own current purposes (see below) – certainly for the moment.
  • Or is it better to hook into the new themes capacity to accommodate variables? I’m slightly wary of that for two reasons: a) if it was trivial, you/Nicolas would probably have already accommodated it. and b) I find it hard to grok the modularised OOP class-based code, probably because I don’t fully understand how they connect or how to hook into them, so am at a loss as to where to start.

In terms of usage, I see two potential situations:

  • Theme prefs, i.e. settings that a theme author might provide for customising certain aspects of the theme. That might be a colour picker, a functionality chooser/excluder, a font chooser, a logo ID#, etc.
    It would make sense that these are provided with the theme, especially if the page/form code depends on them. As we’ve not had themes until now, I’ve not used this yet in my own sites.
  • Site variables, i.e. settings specific to a site but not necessarily a theme. These could be things like google_analytics_id, typekit_id, public url etc. I often have other things in here, for example a list of sections to include/exclude in the menu or sitemap, or a timeline of key dates for a course program that are used throughout the site e.g. application opening, submission deadline, etc. These things are specific to a site but not necessarily a theme. They could be saved elsewhere, e.g. alongside the config or in the doc root.

(Aside: I also looked at etc_variables, which I’d never seen before. It looks promising too but requires some modifications to run on v4.7 (prefs_id no longer exists) and provides a pane for defining the settings for prefs, e.g. choices for a dropdown, but the prefs themselves have to be manually added via phpMyAdmin or an SQL editor. If I’ve understood it correctly, the admin sets the prefs definition and another lower-level admin user can then change the value (in the new tab? not as a preferences panel?)


TXP Builders – finely-crafted code, design and txp

Offline

#74 2018-04-02 08:31:45

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

Re: Theme prefs plugin

You’re right, this was forgotten in the all the themes stuff.

In fact, themes can import prefs. They can import all manner of content – everything except files and images – from XML and .prefs files. We just haven’t formalised it as part of the themes implementation yet.

Take a look in the /setup directory, and pay particular attention to setup_lib.php, from line 131 onwards where it checks the datadir. Early next release that’s on our list to make into proper classes that anyone can use, possibly including core during theme import.

For now, copy the relevant bits of that code into a plugin and hack around with it to taste. Hook into the theme import/update callbacks and that’s all you should need to do.

Last edited by Bloke (2018-04-02 08:32:54)


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

#75 2018-04-02 08:45:35

etc
Developer
Registered: 2010-11-11
Posts: 5,235
Website GitHub

Re: Theme prefs plugin

jakob wrote #310542:

I also looked at etc_variables, which I’d never seen before.

Oh, I have forgotten this one. You are right, it just allows admins to configure data options for various type of inputs (text, select, checkbox etc). Must be well outdated now, at least it will be when Stef’s input widgets land at master.

Offline

Board footer

Powered by FluxBB