Textpattern CMS support forum

You are not logged in. Register | Login | Help

#41 2016-12-20 15:08:18

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,173
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

@Jakob,

I always forget if these are anything to worry about, but in test or debug mode I get this after installing your plugin, jcr_export_txp_templates:

A problem occurred while loading the plugin: jcr_export_txp_templates -> 8192: Methods with the same name as their class will not be constructors in a future version of PHP; jcr_export_txp_template has a deprecated constructor on line 113

textpattern/lib/txplib_misc.php:1782 eval()
textpattern/index.php:193 load_plugins()

I’ll press on with it and see what happens.

UPDATE:

Exported! I first tried by editing the form naming type, type_name, as the docs mention is possible, but it didn’t output any form templates. I switched it back to the default, name_type, and tried again and it worked fine. I can work with that, but just to let you know what I witnessed there.

Last edited by Destry (2016-12-20 15:21:35)


The text persuades, the *notes prove。

Offline

#42 2016-12-20 18:28:01

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,173
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

Just need one clarification, anybody…

Nicolas’ plugin docs describe setting up the Forms folders using the form labels as provided by Txp. But Dale’s tutorial from earlier, notably step 4, makes it sound like you can use whatever folder names you want so long as they are under the parent “forms” folder that the rah_flat plugin reads from. So, is Dale right?

I could have, for example, my rah_flat root directory as…

../flat_parts

Then child folders like this, for example…

  • articles
  • forms
    • article_magic
    • content_components
    • metadata
    • modules
    • static_content
    • template_parts
  • misc

Instead of this…

  • forms
    • article
    • comment
    • links
    • miscellaneous
    • file
    • section

Yes? No?

I’m guessing that maybe you can’t do it that way because if you ever wanted to remove the plugin, or need to turn it off for any reason, then Txp wouldn’t know what to do with the forms if inside child folders not named with default names. Oi?

Last edited by Destry (2016-12-20 19:44:55)


The text persuades, the *notes prove。

Offline

#43 2016-12-20 18:50:31

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 1,438
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

@destry I hope you get it working. And can use your editorial skills to document the process. I have failed twice to make use of this plugin.

i am dying to have it as easy as what Mountee does with Expression Engine and flat files..


…. texted postive

Offline

#44 2016-12-20 19:55:25

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,173
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

Hmm… maybe answering my own Q, I just noticed in Nic’s docs, where it talks about structure, there is a “Custom” folder under the parent “Forms” folder, so maybe the intention is you need to use the stock folders (article, comment, links, etc), plus whatever additional custom folders you want.

I’ll try that, with the assumption you can edit it again later. O_O


The text persuades, the *notes prove。

Offline

#45 2016-12-21 08:00:30

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

@Destry; in my version of rah_flat, forms are stored in the forms folder, and then, in subfolders by form types. For these subfolders you can use native and/or custom form types as names.
If rah_flat is disabled, forms using custom types are altered to use misc because Textpattern does not accept custom types for now (it shows an alert).
‘hope that helps ; I didn’t use jcr_export_txp_templates yet.

Last edited by NicolasGraph (2016-12-21 08:34:01)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#46 2016-12-21 10:37:19

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,173
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

NicolasGraph wrote #303328:

For these subfolders you can use native and/or custom form types as names.

Thanks. That is what I’ve since discovered. And defaulting to “misc” forms on a revert/off situation for any ‘custom’ named forms makes sense.


The text persuades, the *notes prove。

Offline

#47 2016-12-21 14:14:59

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,173
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

bici wrote #303321:

@destry I hope you get it working. And can use your editorial skills to document the process.

I got it working. The confusion, I think, probably comes from people having their own way of tackling the flat-file process (e.g. use different plugins, want different things, etc) so it gets confusing to follow instructions if you’re basing it on the this info and that from here and there.

Following is the nutshell of my attack. With these steps you won’t even need to read the plugin docs:

First, install and activate these two plugins: jcr_export_txp_templates and rah-flat. (I recommend these because they are the latest and actively supported.)

jcr plugin:

  1. In your Txp installation directory, create a new folder called templates. Then create another folder inside that one called export — i.e. ../templates/export. (This is where the jcr plugin will export its initial templates to.)
  2. chmod the export folder (755, 777, whatever you need to do).
  3. In admin-side, go to Extensions > Export templates and hit the Export button. No need to add a name in the field. Your templates will land in /templates/export organized as follows:

- forms
- pages
- plugins
- sections
- styles
- variables

I don’t currently use the resulting plugins , variables , or styles directories, so I immediately delete these three folders. If you need or want them, that’s your homework. I explain styles below.

Also, the forms folder will contain all your forms in batch. You can tell what type they are by the name. You’re going to manually move the types into their own subfolders, but we’ll come back to that shortly.

(oui) rah plugin:

First, decide how you want to structure your templates in your Txp install tree and then create those folders. This is a subjective affair, of course, but I’ll show you how I do it as example… I actually don’t like using the term “templates”, because not all of those flat files are templates, technically speaking. I also prefer using external CSS files, as they don’t require being ‘sucked up’ by the CMS after changes. At the same time, I don’t want multiple extra directories in my root install, so I use a single parent directory (custom) for all static/flat files and split things from there…

  • custom
    • css
    • flatfiles
    • js

In this case the target flat-file directory is: ../custom/flatfiles.

Now, copy the pages, sections, and forms directories from the jcr export folder over to the flat-file container you decide on. For me this is called flatfiles, which helps me remember this folder works in relation to the rah_flat plugin. So I have this:

  • flatfiles
    • pages
    • forms
    • sections

Now we switch focus to the forms folder. Within that are the entire set of form files exported by the jcr plugin. As mentioned earlier, you’re going to create subfolders for each form type and move the form files accordingly. And as Nicolas clarified, you can use Txp form type names for folders, make up your own, or use a combination of both. For the time being, I simply went with Txp’s own form type names because the site in question is new and I don’t have many forms yet. Thus my forms folder is structured like this:

  • forms
    • article
    • comment
    • file
    • link
    • miscellaneous
    • section

I don’t like the label, “miscellaneous”, because it’s not suggestive of anything, so I know I’ll eventually use other folders in place of that one with names like external-code, static-content, modules, widgets, or whatever. If I ever have to kill rah_flat after that for any reason, forms in those custom folders would just drop back into Txp’s miscellaneous type. No big deal.

At this point your form files should be organized into their respective type folders, and they have file names in this pattern: {name}.{type}.txp. If we focus on the article folder from the above branch, for example, files inside will look like:

  • article
    • article_listing.article.txp
    • default.article.txp

Manually edit each file names in each type folder to remove the ‘type’ piece from the name, which is now designated by the name of the containing folder. For example:

  • article
    • article_listing.txp
    • default.txp

Finally, in the admin-side of Txp, go to Admin > Preferences > Template files (rah_flat) and add the relative Template path to the parent flat-file folder. Again, my target path is ../custom/flatfiles.

I also chose “Debugging, Testing” for the upload status option, which seems like a better way to hedge the bets of sucking up. :)

As soon as you click Save, the new flat-file process initializes. At this point you’re using your favorite text editor for all things markup/code. Make sure by doing a test on one of your flat files while in Debug or Test mode and see what happens. It should work barring any external factor.

Clean up

There’s not much to clean up, but you probably won’t need the jcr_ plugin folders anymore, unless you used its templates folder as your parent for final flat-files too. If not…

  1. Delete the templates directory (and contents) from the root install.
  2. Deactivate the jcr plugin.

The text persuades, the *notes prove。

Offline

#48 2016-12-21 14:28:17

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

Destry wrote #303333:

[…] With these steps you won’t even need to read the plugin docs […]

Thanks Destry for sharing your workflow with these two plugins; they should probably fusionate one day…


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#49 2016-12-21 15:19:37

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,173
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

NicolasGraph wrote #303334:

Thanks Destry for sharing your workflow with these two plugins; they should probably fusionate one day…

Agree, a fusion would be convenient, and wouldn’t need much change in workflow, except…

Instead of the export files going to a fixed location (i.e. /templates/export), the Extension panel controls should allow you at that point to designate whatever location you wanted, which then gives you a ready-made path to copy/paste into the rah_flat preferences when ready.

That would eliminate needing to clean up folders between the two plugins.

The user would still have to manually fiddle with the child folders and files a bit, but the plugins would be merged at that point. ;)

And make sure you change the name to oui_flat at that point, or oui_jcr_flat.


The text persuades, the *notes prove。

Offline

#50 2016-12-21 15:35:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,620
Website

Re: oui_flat (rah_flat fork) - Manage templates and prefs as flat files

I like all this stuff, but bear in mind that Themes are-a-comin’ so the process will differ from the above. You won’t need plugins to do it, unless you want your plugin repo under VCS management too (which, btw, you could do with the plugin cache setting in prefs).

Assuming I can get the import/export working reliably then you’ll be able to natively pull and push Theme bundles comprising Pages, Forms and Styles so you can apply them to your Sections as you see fit. There may be the ability to handle prefs too, but it depends on adoption of a patch by makss, which is awaiting ratification.

The core implementation of the file system follows the rah_flat methodology, except for having Form type first in the filename. And, of course, instead of a single folder for your template subdirectories, you’ll have one subfolder per theme, with your template subdirectories beneath each.

NicolasGraph: If you want to help out with the flat-file side of things in core, feel free to pull the themes branch down and let me know. I’ll then share the core flat-file code I have so far, which is currently uncommitted.


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

Board footer

Powered by FluxBB