Kirby Blueprint Reader - Version 0.4

There has been some questions about how to get Blueprint data in a template or a snippet. I just made a plugin for it.

Get blueprint data with the current template

echo blueprint::get();
echo blueprint::field( 'title' );
echo blueprint::item( 'title', 'label' );

Use another template

echo blueprint::get( 'default' );
echo blueprint::field( 'title', 'default' );
echo blueprint::item( 'title', 'label', 'default' );

If you don’t understand it, there are more details in the repository.

Blueprint as plugin name

Maybe it’s going to be a discussion about my name for the plugin, as I call it blueprint, the same name as a core function.

So here are the reasons:

  • I’m out of ideas. I was thinking about calling it smurf but then what would the syntax be? smurf::get('home')?
  • The blueprint class is not already taken by the core and hopefully it will never be.
  • I really like the simple syntax of for example blueprint::get().

Maybe there is a reason for a name change, but I don’t see that right now and I have not alternative names for it. The most important thing I think is that the syntax is rememberable, readable and understandable.

I always like feedback so drop a comment.

5 Likes

Cool idea! As for the name, my two suggestions are bluemanager or bpmanager.

For me, this is a bpmananger:

BP was a gas station. I’m not too fond of that name.

What do you think the syntax should be then?

bluemanager::get();

…or do you still think…

blueprint::get();

…is fine?

Version 0.2 released

I needed to fix some major bugs so it’s a small update.

  • Added support for fallback to default blueprint if no blueprint was found.
  • Fixed a big bug that prevented functions from running.
2 Likes

LOL! My suggestion was based on your doubt about the name. If there’s no reason right now, of course blueprint is way better.

1 Like

Thanks! Even if all suggestions are not perfect I like them, as it gives new perspective on things. So keep’em coming! I’ll keep blueprint a while longer tho. :slight_smile:

@jenstornell:

Thank you very much.

Hint:
Please change the first four echo in the README.md to something like dump( ... ).
echo throws an error

Notice:  Array to string conversion in <filename> on line <linenumber>

[added:]
@jenstornell:
Please change this in the post above too!

Good find! I’ve fixed it now. Thanks! :slight_smile:

I’d say keep it the name simple, like get_blueprint, unless you plan it becoming a real manager.

Looking forward to giving this a shot!

Version 0.2 released

github.com/jenstornell/kirby-blueprint-reader

I almost retired this plugin because of Kirby Architect by @AugustMiller, but instead I just gave it some new life with a rewrite from scratch.

I renamed my plugin from Kirby Blueprint to Kirby Blueprint Reader (or BRead).

BRead

News

  • Caching is now finally a part of this plugin.
  • Support for global field definitions and extended fields.

It has new methods as well

(read the docs in the repository for information on how to use them)

bread::blueprint($template = null)
bread::fields($template = null)
bread::field($key, $template = null)
bread::file($template = null)
bread::read($filepath, $cachekey = null)
bread::parse($array)

I still have a few things to work on like blueprint translations and global field definitions with structure fields which still is not supported.

2 Likes

Version 0.3 released

github.com/jenstornell/kirby-blueprint-reader

With major bug fixes, this release should be much more stable than 0.2. I also added support for structure fields when it comes to global field definitions and extends.

What you might find enjoyable is the Kirby Blueprint Reader VS Kirby Architect. I’ve tried to be as correct as possible. @AugustMiller if you disagree with anything in the table, let me know.

Changelog

  • Fixed major bug with singleton class.
  • Fixed major bug with bread::parse().
  • Added support for global field definitions in structure fields.
  • Added support for global field definitions extends in structure fields.
  • Added compare to Kirby Architect.

@jenstornell Thanks for the comparison, I was about to ask yesterday what would be the differences between the two plugins.

Kirby Blueprint Reader - Version 0.4

github.com/jenstornell/kirby-blueprint-reader

This is probably the biggest update on this plugin so far.

New feature - Array stepping

One of my favorite features is what I call the array step feature. Look at the example below. If type exists in the title field, it will print it, else it will print nothing (because it will be null).

echo b::blueprint('project', 'fields/title/type');

Changelog

  • Support for translations.
  • Support for users blueprints with users/blueprint.
  • Support for multiple caches separated by return type.
  • Support for array step like fields/title/type.
  • Support for global options.
  • Support for .yaml and .php extensions.
  • Changed syntax from bread:: to b::.
  • Changed arguments. Steps added and options is now an array.
  • Changed b::file() to use filename as cache-key instead of path as default.
  • Changed the behavior of the $name argument, which does no longer fallback to default.yml.
  • Docs changed.
  • Bugfixes and code enhancements.
2 Likes