Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-03-10 19:54:59

lindabb
Member
Registered: 2023-02-17
Posts: 132

multi template in one domain

Is it possible to have multi style/template for one site like admin can change colors (style) , this will be useful for some to read.
just like when you change language on some sites .

Thank you

Offline

#2 2023-03-10 20:55:20

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

Re: multi template in one domain

Absolutely. There are a few ways to set it up, and it depends by who you mean ‘admin’ is:

First approach is to use one master stylesheet with all your main rules in it, then a few secondary sheets that set up the CSS variables for the colour/size/style differences, which then ‘@import’ the master sheet. You can just log into the admin side and assign a different style to one or more Presentation>Sections by picking the sheet you want. And of course you can mix and match different styles in different sections if you wish.

But if you’re talking about user stylesheets then the best way is probably with the smd_style plugin (forum thread) which allows you to nominate alternate user stylesheets. Users can flip between them via the stylesheet switcher in their browser, or you can include an on-page switcher via one of the plugin’s tags.

If you do try this plugin, I’d be interested to know how well (or not) it works these days! I’ve not touched the code since 2010 so it might be very out of date. If you hit any issues, I’ll fix it for you. One thing I probably should do is convert the JavaScript to use vanilla JS instead of jQuery. Not sure how much work is involved with that, though it removes one more dependency.


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

#3 2023-03-10 21:31:22

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

Re: multi template in one domain

If you need more than a style switcher, you can install some cookie plugin and go conditional. You can even do it in core, at the price of storing the current template name in URL (like ?f=blue).

Offline

#4 2023-03-10 22:19:26

lindabb
Member
Registered: 2023-02-17
Posts: 132

Re: multi template in one domain

Thank you for all replies,
I meant admin like site, as you know admin can change style,
I want to allow my users change style while on my main page, for example change article colors by selecting from drop down menu to switch between styles:
Dark blue style
Gray style
Green Style
so on.
I will try smd_style plugin , hopefully works for me,

Thank you both

Offline

#5 2023-03-10 22:26:00

lindabb
Member
Registered: 2023-02-17
Posts: 132

Re: multi template in one domain

I assume, I be able to change everything with smd_style plugin (depend on my css ) color, div, position , tables layout so on (whatever in the css and js “if any”) correct ?

Thank you

Offline

#6 2023-03-10 22:59:53

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

Re: multi template in one domain

lindabb wrote #335033:

I assume, I be able to change everything with smd_style plugin (depend on my css ) color, div, position , tables layout so on (whatever in the css and js “if any”) correct ?

Anything that is controllable by CSS can be changed when the user switches stylesheet, yes. But it won’t be able to alter HTML markup or JavaScript.

For that, you’ll need a template switcher instead like etc mentioned above, to switch between forms via the URL.


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

#7 2023-03-10 23:32:10

lindabb
Member
Registered: 2023-02-17
Posts: 132

Re: multi template in one domain

Perfect, thank you both

Offline

#8 2023-03-17 17:26:15

lindabb
Member
Registered: 2023-02-17
Posts: 132

Re: multi template in one domain

Hello Stef,
I have installed smd_style plugin, i did read the help file, but sorry still i have difficultly to understand what to call the switch Let we say I have 4 css
Default
Dark_blue
Gray
Green
if I have drop down combo box to select style, where and how to call the smd_style ? please.

I have this in the page header

<head>
<txp:smd_style
     sheets="default, Dark_blue, Gray, Green" />
<txp:smd_styleswitch wraptag="" />
</head>

and
I have this <ul class="smd_switcher"></ul> on the middle of the page

<body>
<ul class="smd_switcher"></ul>
my articles here..
</body>

but I don’t see anything ? what I’m doing wrong ?

Thank you

Offline

#9 2023-03-17 17:47:44

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

Re: multi template in one domain

Do you load jQuery on the page? It unfortunately requires that library at the moment until I can find time to rewrite all the JavaScript in native JS 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

#10 2023-03-18 12:26:32

lindabb
Member
Registered: 2023-02-17
Posts: 132

Re: multi template in one domain

Thank you Stef,
I added
<script src=“https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.js”></script>
and all links showed, but when I click on the link to switch the css, I see css as text , kind of not executing the code to change the color and css as html.
changes the url to
http://localhost/textpattern/css.php?n=Gray&t=four-point-eight

any idea?

Thank you

Offline

#11 2023-03-18 17:25:55

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

Re: multi template in one domain

Probably jQuery descriptors or selector syntax has changed since I wrote the plugin. I’ll need to take a look at it. Please bear with me.


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

#12 2023-04-03 17:52:56

lindabb
Member
Registered: 2023-02-17
Posts: 132

Re: multi template in one domain

Hello,
Any news about this fix ?

Thanks

Offline

Board footer

Powered by FluxBB