Sign in

Post config options

  • This topic has 2 replies, 2 voices, and was last updated 2 weeks ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3702
    btrem

    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
    BobBob
    Support

    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/

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #3781
    btrem

    Thanks, that did it.

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Post config options’ is closed to new replies.