Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-02-24 20:17:03

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 335
Website

Theme export deletes css

Hi guys, weird one here, I only recently started using themes, when I clicked to export the theme, nothing new was created in the themes folder (thought it might generate a zip or ask me to save a zip locally) and the default.css file was stripped with the default tag at the top, all code gone.. I had a backup thankfully but just wondering what would cause this do you know? And what exactly is export supposed to do? Thank you!

(Textpattern version: 4.7.3)

Last edited by hilaryaq (2020-02-24 20:19:09)


…………………
I <3 txp
…………………

Offline

#2 2020-02-24 20:34:22

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 335
Website

Re: Theme export deletes css

So maybe it’s that duplicated and exported themes must contain the css file in the database? I’m not getting any generated files on the server so css must be within txp to export/duplicate themes?


…………………
I <3 txp
…………………

Offline

#3 2020-02-24 23:21:59

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

Re: Theme export deletes css

hilaryaq wrote #321872:

the default.css file was stripped with the default tag at the top, all code gone

That’s weird indeed. The theme system is many things (mainly awesome) but destroyer-of-content is not supposed to be one of them!

when I clicked to export the theme, nothing new was created in the themes folder

Assuming your themes folder exists and is writable (check Diagnostics panel) all you need to do to get a disk backup copy is check the theme(s) and use multi-edit to export, making sure to uncheck the ‘Delete unused templates from disk on export’ option (because there’s nothing there to delete, although it should do no harm either way).

That will create folders inside /themes, one for each of the selected themes, with its assets beneath. It shouldn’t touch your database – it’s a DB read operation.

Export just allows you to backup your theme to disk so you can either use version control on it, or so you can manually bundle up the theme as a zip file for distribution/storage. It does nothing more. Your site continues to run from the template code stored in the database.

duplicated and exported themes must contain the css file in the database?

Yes. Textpattern enforces a minimum standard for a theme, which includes a default page, an error page, a single default stylesheet and a bunch of ‘essential’ forms. If your database has any of these components missing for a particular theme, they will be created as ‘empty’ placeholder files on disk. Same if you import from disk back into the database. Any base assets not present in the file system will be automatically created in the DB.

Last edited by Bloke (2020-02-24 23:26:35)


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

#4 2020-02-25 11:20:39

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 335
Website

Re: Theme export deletes css

Ah ok, so i think this is what happened: I thought export theme might generate a zip I save locally (wasn’t sure lol), but my theme already existed in the themes folder. So clicking export theme didn’t make any difference to me EXCEPT, I was using an external stylesheet over using css stored at presentation>styles.

So my stylesheet stored at themes-mytheme-styles-default.css was replaced with a blank file, because what was at presentation>styles was blank.

The same thing happens if I duplicate the theme. Now maybe if I rename that stylesheet to something other than default it wouldn’t be wiped? I have yet to test that.. I just hope others wouldn’t make my mistake and not have a backup of their css file!

Thanks Stef :)


…………………
I <3 txp
…………………

Offline

#5 2020-02-25 11:39:50

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

Re: Theme export deletes css

hilaryaq wrote #321890:

clicking export theme didn’t make any difference to me EXCEPT, I was using an external stylesheet over using css stored at presentation>styles.

Right, yes, that’ll be it. If you use the built-in tags, Textpattern will always use the database to serve your assets. But you can, if you like, serve files directly via <txp:output_form> or bulid-your-own URLs. In that case, be careful :)

maybe if I rename that stylesheet to something other than default it wouldn’t be wiped?

If the filename is different to ones in your database, it will be preserved on export IF you leave the ‘delete’ (a.k.a sync everything) checkbox unchecked.

Hope that helps.


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

#6 2020-02-25 11:43:42

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 335
Website

Re: Theme export deletes css

Ok tested that, so naming it something other than default then doesn’t replace the file with a blank page for ‘create duplicate’ (if you left presentation>styles empty), so the css from your external sheet is still there without having been replaced with blank, so it’s non destructive this way which is good.

Clicking export to disk on the created duplicate then works, with a default stylesheet in the styles folder, so you could then manually copy/paste your stylesheet named something else in there and everything works..

I think the shocking bit was just that if you use either duplicate or export on an existing theme which you’re editing your css externally, it will replace your code for the original copy of the theme with the default presentation, which could well be blank if you’re not using it!

Could be something to just add to the documentation maybe? Like a pre duplicate or export check, always paste the code from your stylesheet into presentation>styles first even if you aren’t storing your css there? Just so that people don’t lose their css..


…………………
I <3 txp
…………………

Offline

#7 2020-02-25 11:46:10

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 335
Website

Re: Theme export deletes css

Bloke wrote #321893:

Right, yes, that’ll be it. If you use the built-in tags, Textpattern will always use the database to serve your assets. But you can, if you like, serve files directly via <txp:output_form> or bulid-your-own URLs. In that case, be careful :)

If the filename is different to ones in your database, it will be preserved on export IF you leave the ‘delete’ (a.k.a sync everything) checkbox unchecked.

Hope that helps.

It does thanks Stef, I’m serving the stylesheet with <link rel=“stylesheet” href=”<txp:page_url type=“theme_path” />/styles/default.css”> within the page


…………………
I <3 txp
…………………

Offline

Board footer

Powered by FluxBB