Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2020-08-24 14:33:35

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,321
Website

Re: Testers needed: theme management in 4.8.3

phiw13 wrote #325542:

Oh, i don’t really know why my highly optimised and minified stylesheets can be of any use in the DB, except for linking to it, and even then.

I actually assumed everyone would be doing something like this:

    <!-- CSS
    ================================================== -->
    <link rel="stylesheet" href="<txp:page_url type="theme_path" />/styles/base.css">
    <link rel="stylesheet" href="<txp:page_url type="theme_path" />/styles/vendor.css">
    <link rel="stylesheet" href="<txp:page_url type="theme_path" />/styles/main.css">
    <link rel="stylesheet" href="<txp:page_url type="theme_path" />/styles/default.css">

I guess not.

The first three were included with the theme so I don’t actually edit them. The changes I do make are in default.

Offline

#12 2020-08-24 16:12:05

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,349
Website

Re: Testers needed: theme management in 4.8.3

When making my latest themes, I learned it was much easier for me and the user to use Michael’s method, and I think it was just old habits that stopped me doing it previously. I used
<link rel="stylesheet" href="<txp:page_url type="theme_path" />/styles/<txp:page_url type="theme" />.css">
and so could use the same pages with that code on all 6 themes. For theme makers it also means less instructions needed to give to theme users. By putting the assets in the styles folder too, it makes linking to them in the stylesheet simple. I will be doing all future themes the same way.

If you are not a theme maker, it still makes sense, imho, to have your site design images and fonts in the theme styles folder — less clutter and easy to do. I’ll ask elsewhere about whether other assets can work from there too.


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

#13 2020-08-24 16:28:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,718
Website

Re: Testers needed: theme management in 4.8.3

zero wrote #325547:

to have your site design images and fonts in the theme styles folder

You can do that, but I would be wary of doing so. Simply because Txp assumes stuff inside there is, well, stylesheets. And if you do a full export with sync, Txp is likely to trash anything in that directory that isn’t a css file.

Might be better to put your assets in a parallel directory (or directories), e.g.:

/themes/slim/forms
/themes/slim/pages
/themes/slim/styles
/themes/slim/js
/themes/slim/img

Or:

/themes/slim/forms
/themes/slim/pages
/themes/slim/styles
/themes/slim/assets/js
/themes/slim/assets/img

You can still refer to them using <txp:page_url/>. It also means that if you delete a theme from disk, those assets are guaranteed to be left behind because Txp doesn’t understand them as an official part of a theme.

EDIT: I’ve not tried it, but you might actually want this behaviour so when you delete a theme then all assets go too. Not sure if it does that. It might even leave them behind if they’re in the /styles directory, I’d have to check to be sure.

Last edited by Bloke (2020-08-24 16:45:16)


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

#14 2020-08-24 16:34:35

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,349
Website

Re: Testers needed: theme management in 4.8.3

Bloke wrote #325549:

And if you do a full export with sync, Txp is likely to trash anything in that directory that isn’t a css file.

I wrote:

Yes, I’ve been doing an export without the checkbox ticked.

I wasn’t entirely sure when I wrote that, so I’ve checked again, and found some very interesting results.

I transferred across a test theme which contained test.css and default.css in its styles folder. Also in the styles folder was a css folder which contained 4 other .css files plus more folders for several themes with various things inside those including some more .css files.

So in my remote Themes panel, I had the option to Import the ‘test’ theme, which I did. There was an amber message saying theme test imported and there are 4 css_duplicates (which were the .css files in the css folder and not already on my remote site). I assigned the theme a section and found that I had the option to give it any of the 6 styles — not just test.css and default.css but also the four inside the css folder.

I assigned the test.css to the theme and section and all seemed as normal. So I tried to delete the theme with checkbox unticked and this failed because the theme was using a section. Fine. I checked what that had done to my files and found that all were as when transferred PLUS there were now copies of the four .css files that were in the css folder directly inside the styles folder. Mmm.

I reassigned the section, so the test theme was no longer used, and exported to disk with the checkbox ticked. On checking, all files are just as previously.

So I go back and delete the test theme, with the checkbox unticked. ‘test’ disappears from the Themes list but on checking the files all 6 .css are in the styles folder and all other files and folders are as they were. There’s an option to import ‘test’ theme again, so I do so and get the same results as when I originally imported it, BUT this time 8 .css files are reported as css_duplicates — the four .css files in the css folder times 2.

So without assigning any sections I deleted the test theme again with the checkbox ticked. In an amber warning it says:
Themes deleted: test. Theme files deletion failed for: /path/to/themes/test.

On checking the files I find that all .css files have been deleted, in the styles and in the css folder and also there were some more in the other folders and they were deleted too. The Pages and Forms folders and contents have all been deleted too, and manifest.json. But everything else is intact — all the other folders and files within them. I THINK THIS IS A GREAT FEATURE!

It appears to me that your mapperzapper searches out all .css files, and pages and forms, but leaves the styles folder there if there are folders inside it. And probably would do the same with the pages and forms folders if they had sub-folders too. I like it!

Last edited by zero (2020-08-24 21:20:02)


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

#15 2020-08-24 23:22:15

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 2,110
Website

Re: Testers needed: theme management in 4.8.3

michaelkpate wrote #325546:

I actually assumed everyone would be doing something like this:

I guess not.

Definitely not. That goes against my preference for separation of content and structure – and keeping “structure” files, aka TXP forms and pages separate from “resources” . And it probably is marginally slower than directly linking to a stylesheet / js file / …


Where is that emoji for a solar powered submarine when you need it ?

Offline

#16 2020-08-25 03:32:11

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,321
Website

Re: Testers needed: theme management in 4.8.3

phiw13 wrote #325554:

And it probably is marginally slower than directly linking to a stylesheet / js file / …

Um, that actually allows you to link directly to the file.

I guess it depends on whether you are creating something strictly for yourself that you never plan to change or that either might change or you want to eventually make available for other people. By keeping everything together in the theme folder and linking directly to it, it makes it simple to install or swap out.

Offline

#17 2020-08-25 03:57:10

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 2,110
Website

Re: Testers needed: theme management in 4.8.3

Editor’s Note: I meant to reply to this but accidentally clicked edit instead and can’t restore the original.

Last edited by michaelkpate (2020-08-25 12:16:22)


Where is that emoji for a solar powered submarine when you need it ?

Offline

#18 2020-08-25 07:38:20

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,349
Website

Re: Testers needed: theme management in 4.8.3

phiw13 wrote #325556:

BTW I think the Styles tab should be optional – or merged with some of the different “media forms” the can be created into a “resources” tab to cover stylesheets, scripts, SVG files…

Yes, — assets or resources are more logical names than styles in the themes folder but I don’t know how that would affect backwards compatability if used globally.


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

#19 2020-08-25 13:14:45

etc
Developer
Registered: 2010-11-11
Posts: 3,855
Website

Re: Testers needed: theme management in 4.8.3

zero wrote #325557:

Yes, — assets or resources are more logical names than styles in the themes folder but I don’t know how that would affect backwards compatability if used globally.

All these can currently be considered as custom-type forms, but we have no mechanism (yet) to alter preferences on theme import.

Offline

#20 2020-08-25 13:49:24

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,349
Website

Re: Testers needed: theme management in 4.8.3

etc wrote #325562:

All these can currently be considered as custom-type forms, but we have no mechanism (yet) to alter preferences on theme import.

Making them into custom-type forms would go against the separation of structure and content, as phiw13 stated. Of course, styles doesn’t fit with content either, so perhaps pages, forms, styles and assets/resources would be more appropriate? That doesn’t break anything. And eventually make styles into custom-type forms maybe, if there no longer seems a need for styles?


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

Board footer

Powered by FluxBB