Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2015-06-04 15:15:42

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

Re: Theme prefs plugin

Ok thanks anyway.


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

Offline

#14 2015-06-04 15:27:27

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

Re: Theme prefs plugin

Nice idea! Would solve the adi_variables problem with rah_flat. A couple of questions:

  1. I take it you have to insert the prefs you want yourself into the plugin code. Can you add more prefs without affecting existing ones? As this is mostly dev stuff, I don’t see it as a problem to edit the plugin, but could it be restructured so that you can create an array of pref names and types (text, yes/no, dropdown…) at the top, and then it loops over the all the if_null stuff?
  2. Is it possible at all to have one’s own prefs tab section, e.g. Basic > Advanced > Theme > … etc. (not just the prefs group under advanced).
  3. Would it be possible to restrict editing rights for some of those theme prefs?
  4. Would it make sense to have a corresponding tag for pages and forms to output either each pref individually, or perhaps – so that it could become a drop-in replacement for adi_variables – a single tag that loops over all the prefs and initiates them as corresponding txp variables?

TXP Builders – finely-crafted code, design and txp

Offline

#15 2015-06-04 15:59:13

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

Re: Theme prefs plugin

jakob wrote #291311:

Can you add more prefs without affecting existing ones?

Yes. The if() around the set_pref() takes care of that.

Is it possible at all to have one’s own prefs tab section, e.g. Basic > Advanced > Theme > … etc. (not just the prefs group under advanced).

Not tab, but under 4.6+ we’ve done away with “Advanced” and you get your own twisty group.

Would it be possible to restrict editing rights for some of those theme prefs?

Absolutely, the prefs model has been expanded to allow rights to the group level.

Would it make sense to have a corresponding tag for pages and forms to output either each pref individually, or perhaps – so that it could become a drop-in replacement for adi_variables

I sort of did this with smd_vars years ago. And to some extent in smd_prefalizer. All doable.


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

#16 2015-06-05 06:30:56

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

Re: Theme prefs plugin

jakob wrote #291311:

Nice idea! Would solve the adi_variables problem with rah_flat. A couple of questions:

  1. As this is mostly dev stuff, I don’t see it as a problem to edit the plugin, but could it be restructured so that you can create an array of pref names and types (text, yes/no, dropdown…) at the top, and then it loops over the all the if_null stuff?

That could be nice but I’m not good enough in PHP to do it. It would be great at least to have only one plugin template which would be enhanced and shared for dev and designers. I’ll post my complete code later and we will see what’s happen…


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

Offline

#17 2015-06-05 06:42:50

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

Re: Theme prefs plugin

I was thinking about something I would like to include with this kind of feature. I would like to add a field like sidebar_widgets where the user could enter bio, social, contact for exemple and in my sidebar_form, I would enter this kind of tag <txp:output_form forms='<txp:variable name="sidebar_widgets" />' /> which would display an author bio, a linklist of social networks and a contact form. But I can’t see a way to do it as I can’t use several forms names in <txp:output_form />

Edit: rah_repeat could be my solution, I’ll test it.

Last edited by NicolasGraph (2015-06-05 07:42:46)


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

Offline

#18 2015-06-05 09:56:57

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

Re: Theme prefs plugin

How about this for a first-stab? Install as usual but before you enable it, edit the plugin.

There are two arrays at the top. The first defines the pref groups that will appear and the privilege levels of people who can see them (for 4.6+ at least. For 4.5.x the prefs panel settings are preset to only permit 1,2,3 so anyone else is out of the game). So you can set this to anything you like, e.g.:

protected $plugEvent = array(
        'jcr_whatnot' => '1,3',
        'smd_summat' => '1,3,4',
    );

The second array defines the prefs themselves. The key of each sub-array is the preference name (whose i18n name you can set by adding it to a Textpack), and then its options as follows:

  • Default value
  • Event: The prefs group the preference will appear in. Choose one of the entries from the $plugEvent array you defined above. You can customise its name by setting it in a Textpack.
  • Visibility: usually PREF_ADVANCED for 4.5.x or PREF_PLUGIN for 4.6+. Note, no quotes.
  • Input type (e.g. text_input, yesnoradio, onoffradio. Haven’t done selectList or anything complicated like that yet.
  • Position: number indicating the order of the prefs on-screen, lowest first.
  • Whether the preference is private (set it true to make the pref a per-user setting) or not (false = global).

No idea if it’s of any use, and it doesn’t address point (4) of jakob’s post yet, but play away and suggest improvements.

# Name: oui_prefs v0.10 (compressed)
# Type: Admin plugin
# Set prefs
# Author: NicolasGraph
# Recommended load order: 5

# .....................................................................
# This is a plugin for Textpattern CMS - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

H4sIAAAAAAAAA91YbXPbNhL+7l+B4flKycfIkh2nCVW19bRuz3c5n6fNtdPxZTgQuZTQUACP
AOVoMvnvt1iQFEXSsaftp/KDTQGLfX32BeThbBZ+0OHz0JN8A95ch69CT5UiygtItf39IvR4
adaqsD9mZ6F3I2KVcf19wfM1rU1riqgshF3BBfvv89DbQqGFkvYXiphOZlM6MQu9BHRciNxU
uyj1RzCskYrUsUpIoYvnF7h7enJyxE7Yv7iQLEbxmqWqYDzZCPlMiwRYWsrYcuOZMLsJ0p4e
ObrGmqMPRwwf4mSfE3ablSvkB1uQhlkHaMZlglqIrZ5URDXtN2suV8DMWmhmFNtwE6/ZTpUF
E9KATCBx2rNVocq8xS0T2jCVEtdqc8uzEnoSvt5ytKgo+K5aOaX/eaEMxAb5H+eo7xUpu3CE
I0eJj9+Y6bPFl8yfBWfBuR/Q/nh+9IDl9gAp+ClrSZK1WWOEUHsymkRN2L8lMNSn2LEc3CK6
wx3D+KCTwpojbUIBMobIOsdq2bbhxNmRQMrLzETkogAX7ugNWXLDkKuQGgrrjOWupn17wICC
GbD9c2fWcBAatOR+LTB6pOYSMiVXaMovqmQxl2SlMJoi6IwB9gbem5zH7xhfqi0cCrSso63Q
Yiks9AJ2V+qSZ9mO3f5w9V10+e1PlzffXH1LeH0+uZi8Z/hCW7ev//P99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rwHLBl6YuLGVp5R2COd1pYsxSPZS
tRWFkhu6zFgNq3zeF8Kam7u9ombSzs92YocksCqZRuO0o0F7mt4X1lpPm0l4zXY3bAqRtTEv
Cxx3cNqu1cX+UGa8qBXjdLOoOWvhpnvYWyWlMsjODsmValhj+9b2CrsGGKix4yfW5KYMdipx
Lxvqmd0mA91jbSpUna2bDLYa4ojoag1RB9XU8qn5RdcnhhOL2AxvVWrcVePw28fI3FT8KFlr
Jn6UthqKH6VrRuJHKVuj8dseaW+cOnzrJ/N3YOhGD+1vQi6rcy7B5o3s4f/a+JpV36gQmrn9
jGPzDTGAPWsyxRqH12rfsDXfOjQjhglfac3iMtlyhHrCbmnieeBKOABMq08PlatMLfG+fJws
K63m++pmQVet4mC/wRqEk0ZDiGUXVX6WwBbn9y/YtDfEW3lYtf2vXJMhJT6zw82CVyZUfahV
OIf64e9vIzgRXGotVtJ9XXBfjVwVcx9okJH1tZJgb96/lhv7zWbylDGm0wwGjf6L8z+JilqT
fLthNK8FmBJnQWI0fwB6/3AKtvoIIe7Tl7Pe9NzDQq18b7JzyGkhYw0cS/LIf61iqsIhI7Ms
3bhWGtWWcL8Xiwyq76xml9N31lnondP31tCjz0LV2kW1lmZ8pdt0eHQNWe7Nl+EUf56H3iYh
4vOz0Hv1cnYBy3OA+AymfPpylpxfLD9/9Sp+mcTpi+VLb/7x/9K4BD98FgAA

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

#19 2015-06-05 10:14:14

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

Re: Theme prefs plugin

Bloke wrote #291331:

How about this for a first-stab? Install as usual but before you enable it, edit the plugin.

You did it!? Great!
The only wrong thing for me now is that enable and disable events don’t seem to work (not only for this plugin).
The prefs are added on install. Even if I edit the code before to enable the plugin, original prefs are already there…
Disable and enable it again doesn’t change anything.

…oh, and another thing is that I didn’t already try to use prefs values as variables but I can’t see where values are passed into variables in the code.

Last edited by NicolasGraph (2015-06-05 10:16:12)


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

Offline

#20 2015-06-05 10:21:34

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

Re: Theme prefs plugin

NicolasGraph wrote #291332:

original prefs are already there…

The plugin only cleans up prefs it knows about on deletion, i.e. those that are defined in the $plugEvent variable. If you want to clean up your older prefs, you’ll need to do this:

protected $plugEvent = array(
        'oui_pinbox_t' => '1',
    );

However, the plugin does not currently listen for the disable event because I forgot it (sorry). To remedy that, edit the oui_prefs_welcome() function and add 'disabled' like this:

case ‘deleted’: case ‘disabled’:

That will run the cleanup every time the plugin is disabled, removing any prefs and lang strings that are defined in $plugEvent. The plugin should probably leave the lang strings alone on disabling, and only actually delete them on plugin deletion. I’ll fix that later for you, but for now this will (sort of) work.


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

#21 2015-06-05 10:25:47

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

Re: Theme prefs plugin

Bloke wrote #291333:

I’ll fix that later for you.

Actually it was too simple not to do now:

# Name: oui_prefs v0.10 (compressed)
# Type: Admin plugin
# Set prefs
# Author: NicolasGraph
# Recommended load order: 5

# .....................................................................
# This is a plugin for Textpattern CMS - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

H4sIAAAAAAAAA91Y7XPbNBj/3r9CZwpOipc2bbcxh8B60I3CKL0x4Liy8ym2nIg5kpHkdLnd
/ncePZITx3bX3oAv+EPrWI+e19/zItF4PI7f6fg0DgRdsmCi4ydxICuelIrl2v5+FAe0Mgup
7I/xcRxc8lQWVD9XtFzgt6OaIqkUt1/gg/33OA5WTGkuhf0FIo5G4yPcMY6DjOlU8dL4VZD6
MzNkIxWoU5mhQg8fnQLDw4ODPX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rI
WDAKrXcQvpApdtuYoFmWblgrDWoLdrMVCwz85bBZl3g5PI6DE7wkjgO8y/LfHvpveUHnukkH
WxesKIPJLD6CnydxsMyQ+OQ4Dk5P8ocsOz0+TSkdH89O0sen7MmTdPzF4+NHKZ09Dibv/wZ+
9HBgMRcAAA==

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

#22 2015-06-05 10:26:00

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

Re: Theme prefs plugin

Bloke wrote #291333:

The plugin only cleans up prefs it knows about on deletion, i.e. those that are defined in the $plugEvent variable. If you want to clean up your older prefs, you’ll need to do this…

In fact I talked about the prefs included in the plugin code above: pref_name1 and pref_name2.


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

Offline

#23 2015-06-05 10:27:34

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

Re: Theme prefs plugin

NicolasGraph wrote #291335:

In fact I talked about the prefs included in the plugin code above: pref_name1 and pref_name2.

They’re defined under the oui_prefs event so as long as that is in $plugEvent, they’ll be deleted. Try installing the version of the plugin I just posted and disable it. The prefs should disappear.


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

#24 2015-06-05 10:30:46

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

Re: Theme prefs plugin

NicolasGraph wrote #291332:

I can’t see where values are passed into variables in the code.

They’re not (yet). That requires a public callback to read the pref values. Very simple, should only be a few lines of code.


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

Board footer

Powered by FluxBB