Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2016-09-07 19:21:29

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

hcgtv wrote #301201:

Have you tried cxc-templates?

Yeah, looks like it would only require a small mod to make the sections output json… I kinda prefer mem_templates which is a fork of cxc. But they’re both useful.

Offline

#38 2016-09-07 20:02:58

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

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

My updated version of the exporter does export section.json files.


TXP Builders – finely-crafted code, design and txp

Offline

#39 2016-09-07 20:42:56

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

jakob wrote #301208:

My updated version of the exporter does export section.json files.

Oh! delightful… thanks

[Edit]

Man, if you wanted to be insanely heroic, you could put forms into subfolders named by type.

[Edit]

Wish I knew how to contribute to your github repo… just updated so that you can set an empty value for form naming scheme and it’ll omit the “type” in names on export.

} else if ($this->_config['form_naming_scheme'] == 'type_name'){
    $file_name = (isset($row['type']) ? ".".$row['type'] : "") . $row['name'];
} else {
    $file_name = $row['name'];
}

So now you really would just have to figure out how to do subfolders by form type.

Offline

#40 2016-12-20 10:48:32

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

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

jakob wrote #301208:

My updated version of the exporter does export section.json files.

I’m going to use this, when I get to that point.

Btw, in the ReadMe file, first section, the “oui_flat” link should be https://github.com/NicolasGraph/rah_flat, though I like your name better for the distinction.

Offline

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

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
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)

Offline

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

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
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)

Offline

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

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

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
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
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

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
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
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.

Offline

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

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
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.

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

Board footer

Powered by FluxBB