Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2018-12-29 19:02:17

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: flat scripts in 4.7.2

bici wrote #315831:

i hope this is where i post this question. In the new year i am going to finally give TxP and editing Flat Files a go. So what do i need to download/install to get started?

This is easy:) As from the latest version(s), you do not need to download anything. You could do everything on TextEdit on mac, PlainText on pc, or you could use an html editor of your choice. If there is one thing not installed in most computers but you most definitely have already is an ftp client:)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#26 2018-12-29 21:47:06

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: flat scripts in 4.7.2

colak wrote #315832:

This is easy:) As from the latest version(s), you do not need to download anything.

But etc_flat can be helpful if you want to develop using flat files. The difference is:

  • regular situation:
    • your pages, forms and styles are stored as usual in the database, now grouped by theme. You can export these to disk to save them as files in the /themes folder.
    • you can edit the flat files on disk as well but it has no effect until you import the files from disk to the database.
  • with etc_flat:
    • When working in testing or debugging mode, textpattern fetches the flat files directly from the disk, by-passing the database.
    • When working in live mode, the database versions are used. To make the live version match your testing version, you need to import the theme from disk to the database.

So, etc_flat is not needed but helpful in practice when developing. Please correct me if I am mistaken.


TXP Builders – finely-crafted code, design and txp

Offline

#27 2019-02-01 13:46:31

ia278
Member
From: UK
Registered: 2018-11-07
Posts: 17
Website

Re: flat scripts in 4.7.2

etc wrote #315739:

that should be format

<txp:output_form form="jquery.js" format="flat.script" />...

I’m having a problem with this too…

So what I’ve done is create a generic form called myscript.js, and then called it using;

<txp:output_form form="myscript.js" format="script" mediatype="application/javascript" />

Is this correct? Because although the source code spits out a script tag with the required src, the actual link shows an empty page…

Last edited by ia278 (2019-02-01 14:49:23)

Offline

#28 2019-02-01 14:25:45

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

Re: flat scripts in 4.7.2

ia278 wrote #316398:

To use this, you must create a custom js form type in Advanced options:

[js]
mediatype="application/javascript"

although the source code spits out a script tag with the required src, the actual link shows an empty page…

Then assign js type to myscript.js form and save it to disk (via Export to disk checkbox or Theme export). Then

<txp:output_form form="myscript.js" format="flat.script" />

should work. Or fetch the form from db with (mind .js extension)

<txp:output_form form="myscript.js" format="script" />

Or rename it to just myscript (without .js) and use your code (mediatype attribute is not needed).

Hope that helps.

Offline

#29 2019-02-01 15:06:32

ia278
Member
From: UK
Registered: 2018-11-07
Posts: 17
Website

Re: flat scripts in 4.7.2

You’ve definitely helped – I can see the root of the problem a bit better now! Thanks!

So, I’ve added [js] mediatype="application/javascript" title="JavaScript" to the advanced options (even though it’s the same as the stuff that comes by default, minus the ;?), and managed to get the database version working – but I don’t think the flat file version is?

I remember seeing this;

  • path/to/site/index.php?f=hello.js will serve the parsed db version
  • path/to/theme/forms/js/hello.js will serve the unparsed flat file version

I’m only getting the former. And I’ve not seen the Export to disk checkbox at all (which I assume I need to do to save the form as a flat file)…

Last edited by ia278 (2019-02-01 15:31:25)

Offline

#30 2019-02-01 15:56:34

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

Re: flat scripts in 4.7.2

Fine, getting closer. Custom form types are in ini format, ; is just a comment. Have you ever exported your theme to disk? To be sure, go to Themes tab, select the current theme and try to export it. This should enable export checkbox for forms, pages and styles. Once hello.js is exported, you should be able to use its flat copy.

Offline

#31 2019-02-01 15:58:22

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: flat scripts in 4.7.2

The ‘Export to disk’ to disk appears under all my forms/pages for me. The other way to do it is to go to Presentation>Themes, Tick on the Theme and then use the pull-down to export all your theme (including the js, css, forms, pages, etc) to the disk.

>Edit… Oleg was faster:)

Last edited by colak (2019-02-01 16:00:42)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#32 2019-02-01 16:59:23

ia278
Member
From: UK
Registered: 2018-11-07
Posts: 17
Website

Re: flat scripts in 4.7.2

etc wrote #316403:

Fine, getting closer. Custom form types are in ini format, ; is just a comment. Have you ever exported your theme to disk? To be sure, go to Themes tab, select the current theme and try to export it. This should enable export checkbox for forms, pages and styles. Once hello.js is exported, you should be able to use its flat copy.

colak wrote #316404:

The ‘Export to disk’ to disk appears under all my forms/pages for me. The other way to do it is to go to Presentation>Themes, Tick on the Theme and then use the pull-down to export all your theme (including the js, css, forms, pages, etc) to the disk.

>Edit… Oleg was faster:)

I don’t think I’ve ever been in the themes tab! :-) I’ve got the checkbox up now, so thanks a lot!

I’m also just realising what a massive improvement being able to create custom form types is – organising information just got a lot easier!

Thanks again for your help, much appreciated! :-)

Offline

Board footer

Powered by FluxBB