Trying to default new pages to not visible but it's not setting visible:false in the front matter

Hi, have a blueprint for a custom page type (a property listing for real estate), and I want to set each of those to be not visible so they do not show up in the navigation menu. I created a custom “Add New Page” blueprint in /user/blueprints/admin/pages:

form:
    validation: loose
    fields:
        section:
                type: section
                title: Add a Property Listing

        title:
            type: text
            label: Listing Title
            validate:
                required: true

        folder:
            type: hidden
            default: '@slugify-title'

        route:
            type: hidden
            default: /active-inventory

        name:
            type: hidden
            default: 'listing'

        visible:
            type: hidden
            default: 1

        blueprint:
            type: blueprint

Note: I’ve tried both 1 and false for the default value of visible

I’ve also modified the listing template so that it add the value to include the override for visible:

title: Listing
'@extends':
    type: default
    context: blueprints://pages


form:
  fields:
    tabs:
      fields:
        content:
          title: Listing
          fields:
            content:
              unset@: true
            header.address:
              type: text
              label: Street Address
            header.city:
              type: text
              label: City
            header.zip:
              type: text
              label: Zip Code
            header.county:
              type: select
              label: County
              options:
                Atlantic: Atlantic
                Bergen: Bergen
                Burlington: Burlington
                Camden: Camden
                Cape May: Cape May
                Cumberland: Cumberland
                Essex: Essex
                Gloucester: Gloucester
                Hudson: Hudson
                Hunterdon: Hunterdon
                Mercer: Mercer
                Middlesex: Middlesex
                Monmouth: Monmouth
                Morris: Morris
                Ocean: Ocean
                Passaic: Passaic
                Salem: Salem
                Somerset: Somerset
                Sussex: Sussex
                Union: Union
                Warren: Warren
              default: Hunterdon
            header.pool:
              type: toggle
              label: Pool
              highlight: 1
              help: 'Does the property have a pool?'
              options:
                1: PLUGIN_ADMIN.YES
                0: PLUGIN_ADMIN.NO
              validate:
                  type: bool
              default: 0
            header.garage:
              type: toggle
              label: Garage
              highlight: 1
              help: 'Does the property have a garage?'
              options:
                1: PLUGIN_ADMIN.YES
                0: PLUGIN_ADMIN.NO
              validate:
                  type: bool
              default: 0
            header.fireplace:
              type: toggle
              label: Fireplace
              highlight: 1
              help: 'Does the property have a fireplace?'
              options:
                1: PLUGIN_ADMIN.YES
                0: PLUGIN_ADMIN.NO
              validate:
                  type: bool
              default: 0
            header.warranty:
              type: toggle
              label: Home Warranty
              highlight: 1
              help: 'Does the property have a warranty?'
              options:
                1: PLUGIN_ADMIN.YES
                0: PLUGIN_ADMIN.NO
              validate:
                  type: bool
              default: 0
            header.rooms:
              type: text
              label: Rooms
              validate:
                type: number
            header.bedrooms:
              type: text
              label: Bedrooms
              validate:
                type: number
            header.bathrooms:
              type: text
              label: Bathrooms
              validate:
                type: number
            header.lotsize:
              type: text
              label: Lot Size
              validate:
                type: number
            header.directions:
                type: textarea
                label: Directions
            header.price:
              type: text
              label: List Price
              validate:
                type: number
              help: 'List price, numbers only, do not add $'
            header.taxes:
              type: text
              label: Taxes
              validate:
                type: number
              help: 'Taxes, numbers only, do not add $'
            header.content:
                type: textarea
                label: Description
            header.testfield:
                type: textarea
                label: test
            header.interior:
                type: textarea
                label: Interior Features
            header.exterior:
                type: textarea
                label: Exterior Features
            header.leadimage:
              type: pagemediaselect
              folder: '@self'
              label: Lead Image
              preview_images: true
            header.media_order:
              label: Images
              ordering@: 99
      advanced:
        fields:
          overrides:
            fields:
              header.visible:
                default: false

Neither have any effect. New pages that are create default to being visible.

What am I missing?

@ChyrstalSolutions, My guess is…

  • pages that do not have a numeric prefix have their internal ‘visible’ property automatically set to ‘false’.
  • the ‘listing’ pages you create do not have a numeric prefix
  • therefor there is no need to add this property to the frontmatter of the page.

However, when you set in your page creation modal the value for visible to ‘true’:

visible:
  type: hidden
  default: true

you will see that in the new page in Admin Panel, the value for ‘visible’ is set to ‘Enabled’ and when the page is saved, the frontmatter contains `visible: true’. It now needs to override the default value ‘false’ for pages without a numeric prefix.

By the way, in the page blueprint for ‘Listing’ you can leave out the following setting because its value is already passed-on by the page creation modal.

advanced:
  fields:
    overrides:
      fields:
        header.visible:
          default: false

Note: After changing blueprints, its best to clear the cache.

Thank you @pamtbaau or your suggestions. I do have numeric prefixes turned on because I want the content author to be able to manually change the order of the pages.

I tried your suggested change to the Page Creation Modal. Unfortunately, I did not see any change to the created page.

Any other thoughts?

@ChyrstalSolutions,

I did some tests with the standard ‘new page’ modal and ‘default’ page template and the results are basically the same as the tests I did before.

I think it is time to create an issue at github.com/getgrav/grav-plugin-admin

@pamtbaau, I was about to say, “But it works fine on my other site, and I took these blueprints directly from there!” Then I went back and tested that other site, and it’s doing the same thing, and it didn’t before. I will create the issue as you suggested.