Page 1 of 1

Real World Examples for Custom Fields

Posted: Mon Mar 09, 2020 8:42 pm
by bbyrdhouse
I am using 3.11.0 and there is a setting for "Custom Fields" with a link to the documentation that takes you here: https://docs.bludit.com/en/content/custom-fields

My question is, are there real world examples or explanations as to what these do?

Example:

Code: Select all

{
    "youtube": {
        "type": "string",
        "label": "YouTube",
        "tip": "Write the YouTube URL."
    }
}
What does that produce?
Where does it get produced at?
Who sees it? The site visitor or the website admin ... or the theme developer?

It sounds like a nice feature, but I've no idea what it is suppose to accomplish. More information would be helpful.

Gary

Re: Real World Examples for Custom Fields

Posted: Tue Mar 10, 2020 8:47 am
by diego
Hi,
custom fields are for the admin panel, but you can show the content of the custom field in the theme (for the visitors).

The example will add a custom field with a input text in the editor page. You can add information in this custom field such as a Youtube URL and then you can show a Youtube video in your theme.

It would be good if you can help me to improve the documentation to provide a better explanation for custom fields, feel free to create a PR for this page.
https://github.com/bludit/documentation ... s/index.md

Regards

Re: Real World Examples for Custom Fields

Posted: Sat Apr 18, 2020 2:17 pm
by hxii
My usecase is fairly simple, but I use custom fields to denote which post/page is deemed "important".
Screen Shot 2020-04-18 at 3.17.23 PM.png
Screen Shot 2020-04-18 at 3.17.23 PM.png (91.6 KiB) Viewed 4227 times

Re: Real World Examples for Custom Fields

Posted: Thu Apr 30, 2020 2:04 pm
by SamBrishes
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

Image

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.