Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 Today 03:38:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,088
Website GitHub

Admin theme customisation

Leading question:

Does anybody currently add a file called prefs.json to their admin theme installation folder, to define additional public-side prefs and style blocks?

If I’m reading this Theme code right:

        if (!empty($prefs['textpattern'])) {
            $content = json_encode($prefs['textpattern'], TEXTPATTERN_JSON);
            $out .= \Txp::get('\Textpattern\UI\Script', "textpattern.prefs = jQuery.extend(textpattern.prefs, {$content})").n;
        }

        if (!empty($prefs['style'])) {
            $content = $prefs['style'];
            $out .= \Txp::get('\Textpattern\UI\Style', n.$content.n);
        }

That allows you to add a ‘textpattern’ node to prefs.json in any admin theme folder, which will extend the public JavaScript `textpattern.prefs` object with your own. Presumably that’s for adding JS strings and stuff that your theme might need, over and above what’s in core already.

In addition, it will inject any content defined in a prefs.json ‘style’ node as inline styles.

The above is in addition to using custom.css and/or custom.js, which will read those files (not content) and add them as <link> targets to be loaded with your theme.

I’m only asking because I have a half-baked enhancement that I might squeeze into 4.9.0 if there’s time between now and next weekend, and if nobody is using this prefs.json file, I’m tempted to rename it because it’s a daft name for what it does.


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

#2 Today 06:03:29

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,537
Website

Re: Admin theme customisation

I did not know this option eventually existed – and at first sight, it is not documented (I may have missed that though). So no, unused on my side.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#3 Today 07:32:07

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,066
Website GitHub

Re: Admin theme customisation

Same here.


TXP Builders – finely-crafted code, design and txp

Offline

#4 Today 07:52:28

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,088
Website GitHub

Re: Admin theme customisation

That’s what I hoped the answer would be from both people I expect are the only candidates for using this undocumented feature :)

Thank you. If I can get this thing to work then I’ll rename the file to custom.json instead.

Any more people using it?


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