Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

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

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,470
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)


BB6 Band My band
Gud One My blog

Offline

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

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,235
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 ?
Sand space – admin theme for Textpattern

Offline

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

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

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: 3,235
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 ?
Sand space – admin theme for Textpattern

Offline

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

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
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.


BB6 Band My band
Gud One My blog

Offline

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

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

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,470
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?


BB6 Band My band
Gud One My blog

Offline

#21 2020-08-25 14:03:25

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

Re: Testers needed: theme management in 4.8.3

phiw13 wrote #325556:

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

Something strange happened to me too, when replying to Stef’s comments in this post. I started writing after I’d done the importing, exporting and deleting, and then couldn’t quite remember exactly what I had done, so I did it all again, whilst writing the post at each step. Because it took so long I think, I ended with my post but the original disappeared.


BB6 Band My band
Gud One My blog

Offline

#22 2020-08-26 05:05:38

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,235
Website

Re: Testers needed: theme management in 4.8.3

So, after seeing this comment, I did a test again. Up to someone else to decide if the 4.8.3 behaviour is expected or “correct”or…

with TXP 4.8.3-pre GH fresh download – remove all references to stylesheets for each section on the “sections” panel and delete all / any existing stylesheets on the “styles” panel (the sections pages link to a stylesheet directly anyway).

on export:

Themes exported: theme_name.
No style data found for: theme_name.

on import (after renaming the theme for my convenience):

Themes imported: theme_name_2.
Warning: cannot read from directories/files /Users/user_name/Sites/test-local/themes/theme_name_2/styles.

a new default.css is created, with as content:

/* Contents of the css tag goes here. See https://docs.textpattern.com/tags/css */

–––
on TXP-dev 4.9.0

similar behaviour on export.
on importing, no warning or error.
and same as with 4.8.3 latest GH code, a new default.css is created

edited to clarify the configuration

Last edited by phiw13 (2020-08-26 06:06:36)


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

Offline

#23 2020-08-26 05:16:30

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,235
Website

Re: Testers needed: theme management in 4.8.3

hold on… on the “styles” panel, in my comment above I had selected the newly imported theme_name_2 to see if yes/no a stylesheet had been created.

issue:

when toggling back to theme_name (live theme in use, with NO stylesheet included in the DB anymore) I got a whole bunch of Notices and Warnings

Notice "Undefined index: theme_name"
Warning "in_array() expects parameter 2 to be array, null given"
Warning "reset() expects parameter 1 to be array, null given"
Warning "array_slice() expects parameter 1 to be array, null given"

etc, all in /Users/username/Sites/test-local/textpattern/vendors/Textpattern/Skin/AssetBase.php around line 314 and down

that is with the 4.8.3 codebase

when the loading the panel ‘normally’ with theme_name already selected no notices or warning.


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

Offline

#24 2020-08-31 06:18:28

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,235
Website

Re: Testers needed: theme management in 4.8.3

phiw13 wrote #325569:

issue:

when toggling back to theme_name (live theme in use, with NO stylesheet included in the DB anymore) I got a whole bunch of Notices and Warnings […]

Unsurprisingly, now that the code has landed / has been merged with 4.9.0-dev, I have seen the same warning(s) and notices.


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

Offline

Board footer

Powered by FluxBB