Jump to content

Defining templates as JSON?


JayGee
 Share

Recommended Posts

I think I saw post on here or an article in the newsletter about a forthcoming feature for defining/importing templates using a JSON file… or did I completely imagine this?! ?

If it’s real I can’t find the info anywhere!

Link to comment
Share on other sites

16 minutes ago, kongondo said:

Not sure if this is the one...it is about translations..

 

Thanks - but I don’t think that’s the one. I think it was in one of the newsletters discussing dev branch updates. It was more along the lines of creating new templates using a text or json file to define the fields.

Had some ideas around experimenting with this in our workflow… but now seriously beginning to wonder if I dreamed it ???

 

Link to comment
Share on other sites

That sounds like the recent talk on making it easier to version and export fields and templates, CI&CD, etc. I don't think. You can currently define (export) and import templates and fields using JSON (not JSON file, unless using its API). This feature has been around for a while. This was also pointed out in the aforementioned discussion. I'll see if I can find the link if that's what you are after? 

Edited by kongondo
Link to comment
Share on other sites

You are not dreaming - this is already possible using RockMigrations:

<?php
$rm->migrate([
    'fields' => [
        'myfield1' => [
            'type' => 'text',
            'label' => 'My field one',
        ],
        'myfield2' => [
            'type' => 'text',
            'label' => 'My field two',
        ],
    ],
    'templates' => [
        'mytemplate' => [
            'fields' => [
                'myfield1',
                'myfield2',
            ],
        ],
    ],
]);

If you don't like PHP arrays for whatever reason simply use json_decode( _your_fields_and_templates_as_json_string_ ) instead...

I'll release a new version soon that makes it a lot easier to get started with RockMigrations though the API will 99% be the same as in the old module.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

4 hours ago, bernhard said:

You are not dreaming - this is already possible using RockMigrations:

<?php
$rm->migrate([
    'fields' => [
        'myfield1' => [
            'type' => 'text',
            'label' => 'My field one',
        ],
        'myfield2' => [
            'type' => 'text',
            'label' => 'My field two',
        ],
    ],
    'templates' => [
        'mytemplate' => [
            'fields' => [
                'myfield1',
                'myfield2',
            ],
        ],
    ],
]);

If you don't like PHP arrays for whatever reason simply use json_decode( _your_fields_and_templates_as_json_string_ ) instead...

I'll release a new version soon that makes it a lot easier to get started with RockMigrations though the API will 99% be the same as in the old module.

Ah brilliant thanks - think this is what I was thinking of ?.

Nothing against php arrays either, in my mind I was thinking of JSON for some reason.

Although I’m considering a workflow that has gulp in it anyway, so json may be involved at some point. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...