Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Post config options

  • #3702
    Avatar photo[anonymous]

    Do post config options work in theme overrides? I tried to add a field to posts in blank-override/config.json :

    "postConfig": [
        {
            "name": "scientificName",
            "label": "Scientific name:",
            "placeholder": "Enter scientific name of plant",
            "value": "",
            "type": "text"
        }
    ],

    I entered text in the “Scientific name” text box in the post editor.

    I added elements in my front page index.hbs :

    {{#each posts}}
    
    <article class="plant">
    
        <header>
            {{! post title }}
            <h1>{{title}}</h1>
            {{! /post title }}
    
            <p class="scientificName">{{@config.post.scientificName}}</p>
    
            
    {{@postViewConfig.scientificName}}

    Result:

    <article class="plant">
    
        <header>
            <h1>aster</h1>
    
            <p class="scientificName"></p>
    
            
    #3712
    Avatar photoBob

    Hi btrem,

    Everything is fine except one thing: because you are trying to use post config options outside the post page you have to use the postViewConfig object and that’s exactly what you did, but the syntax is wrong, do not use at sign (@):

    <div class="scientificName">{{postViewConfig.scientificName}}</div>

    more in this topic: https://getpublii.com/dev/theme-settings-api/#howtoaccessoptionvaluesofthethemesettingsinthetheme and https://getpublii.com/dev/post-config-options/

    #3781
    Avatar photo[anonymous]

    Thanks, that did it.

    (And I’ll work on my apparently poor copy/paste skills.)