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::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?
blueprint class is not already taken by the core and hopefully it will never be.
- I really like the simple syntax of for example
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.
Cool idea! As for the name, my two suggestions are
For me, this is a
BP was a gas station. I’m not too fond of that name.
What do you think the syntax should be then?
…or do you still think…
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.
LOL! My suggestion was based on your doubt about the name. If there’s no reason right now, of course
blueprint is way better.
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.
Thank you very much.
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>
Please change this in the post above too!
Good find! I’ve fixed it now. Thanks!
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
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).
- 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)
I still have a few things to work on like blueprint translations and global field definitions with structure fields which still is not supported.
Version 0.3 released
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.
- Fixed major bug with singleton class.
- Fixed major bug with
- 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
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
echo b::blueprint('project', 'fields/title/type');
- Support for translations.
- Support for users blueprints with
- Support for multiple caches separated by return type.
- Support for array step like
- Support for global options.
- Support for
- Changed syntax from
- Changed arguments. Steps added and options is now an array.
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
- Docs changed.
- Bugfixes and code enhancements.