Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2015-06-04 15:01:49

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

Re: Theme prefs plugin

Bloke wrote #291307:

Sadly, for 4.5.x the only way is to use jQuery to intercept the help clicks on certain elements and replace them with your own handler.

From 4.6+ there’s a callback in the popHelp() function to allow plugins to customise the content. There will also be some helper functions to render standard help templates to fit in with the current theme, plus we’ve introduced the notion of inline help to show up on-screen, which is manipulated through Textpacks for full i18n.

Ok, thanks. Any idea about the 4.6 release date?


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

Offline

#12 2015-06-04 15:10:01

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,495
Website

Re: Theme prefs plugin

NicolasGraph wrote #291308:

Ok, thanks. Any idea about the 4.6 release date?

Not tomorrow :-)


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

#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
Moderator
From: Germany
Registered: 2005-01-20
Posts: 3,228
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: 8,495
Website

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: 8,495
Website

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
uy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9NzDQq18b7JzyGkhYw0cS/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: 8,495
Website

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

Board footer

Powered by FluxBB