Forum

Thread tagged as: Question, Problem

Republish feature

I've added a new checkbox field to a template to allow the content to be hidden:

<perch:content type="checkbox" id="hide" label="Hide" suppress="true" value="1" divider-before="Visibility" />

However, for it to work I seem to have to go through each page where I have this region and save changes. I thought the republish feature would do that work for me but it doesn't have any effect. The only way seems to be to manually go through saving every region in the admin that uses that template. Is there something I have missed?

(Perch: 2.8.34)

Stephen Turvey

Stephen Turvey 0 points

  • 3 years ago

That should do it, so long as it’s not a region using perch_content_custom()

Drew McLellan

Drew McLellan 2638 points
Perch Support

Republish regenerates the cached HTML based on the current state of the content and the template.

By adding a field that has no value in the content, the value of hide will be unset unless you load up each item and check the box.

The only way to do it would be to invert the logic and make your 'hide' field a 'show' one.

it IS using perch_content_custom() !

Stephen, Drew’s answer is still the proper one in this situation because the region has a default template, so a second thought about my answer leads me to retract it.

Perhaps there is an easier way to achieve what I need? I just want to hide a certain page temporarily, so there are no links to it, but the page should still exist if you go directly to it.

I've ticked to hide the page from main nav and removed it from navigation groups. The issue is the link still appearing on the site wherever I use perch_content_custom, for example:

<?php
            perch_content_custom('Program overview', array(
                'page' => '/teach-english/*',
                'template' => 'programs/program_teaser_overview.html',
                'count' => 24,
                'filter'=>'overview_type',
                'match'=>'eq',
                'value'=>'Volunteer',
                'sort'=>'overview_country',
                'sort-order'=>'ASC',
            ));
            ?>

. Hence I tried adjusting this to:

<?php
            perch_content_custom('Program overview', array(
                'page' => '/teach-english/*',
                'template' => 'programs/program_teaser_overview.html',
                'count' => 24,
                'filter'=> [
                    [
                        'filter'=>'overview_type',
                        'match'=>'eq',
                        'value'=>'Volunteer'
                    ],
                    [
                        'filter'=>'hide',
                        'match'=>'neq',
                        'value'=>1,
                    ],
                ],
                'sort'=>'overview_country',
                'sort-order'=>'ASC',
            ));
            ?>

Or replace the page template in the page settings for now, then change it back when you want it again.