Hellow,
today I switched to the Custom Fields too! :D
Previously I denoted the meta stuff as HTML comment on the bottom of the content and fetched them on the theme directly. I'm glad, that I don't have to do that anymore, because this was really annoying.
My Custom JSON:
Code: Select all
{
"label": {
"type": "string",
"label": "Post Label",
"placeholder": "Additional Post Label"
},
"wip": {
"type": "bool",
"label": "Product Page Settings",
"tip": "Work in Progress"
},
"discontinued": {
"type": "bool",
"tip": "Product discontinued"
},
"github": {
"type": "string",
"label": "GitHub Slug",
"placeholder": "GitHub Slug"
},
"bludit": {
"type": "string",
"label": "Bludit Slug",
"placeholder": "Bludit Plugins-Page Slug"
},
"plus": {
"type": "string",
"label": "Plus Slug",
"placeholder": "URL to Buy the Plus Package"
}
}
and this results in
and this gets shown directly on the template such as
Code: Select all
<?php if(!empty($page->custom("plus"))){ ?>
<div class="plugin plugin-button">
<a href="<?php echo $page->custom("plus"); ?>" class="button button-red button-outline button-block">
<span class="icon icon-rocket"></span>Purchase <?php echo $page->title(); ?>+
</a>
</div>
<?php } ?>
<?php if(!empty($page->custom("github"))){ ?>
<div class="plugin plugin-button">
<a href="https://www.github.com/<?php echo $page->custom("github"); ?>/archive/<?php echo $meta["version"]; ?>.zip" class="button button-green button-outline button-block">
<span class="icon icon-desktop-download"></span> Download <?php echo $page->title(); ?>
</a>
</div>
<?php } ?>
<?php if(!empty($page->custom("bludit"))){ ?>
<div class="plugin plugin-button">
<a href="https://plugins.bludit.com/<?php echo $page->custom("bludit"); ?>" class="button button-primary button-outline button-block">
<span class="icon icon-bludit"></span> Bludit Website
</a>
</div>
<?php } ?>
<?php if(!empty($page->custom("github"))){ ?>
<div class="plugin plugin-button">
<a href="https://www.github.com/<?php echo $page->custom("github"); ?>" class="button button-primary button-outline button-block">
<span class="icon icon-mark-github"></span> GitHub Repository
</a>
</div>
<?php } ?>
It's way easier and way more comfortable as using comments... And a small tip: Use
jsonLINT to validate your JSON code before storing them on the Bludit administration. It helps to find a wrong syntax.
Sincerely,
Sam.