Forum

Thread tagged as: Question, Runway

How do I hide/unpublish content?

I thought that the "Draft" feature could be used to hide content and make sure it won't appear on the website and search results, but this doesn't seem to be the case.

What's the best way to hide/unpublish content and make sure it won't appear on the website?

Do I have to create a "hide" checkbox for each collection template, and then filter the items where "hide" isn't equal to "true" across all pages? The content would still appear in search results, there must be a better way.

Stéphane Mégécaze

Stéphane Mégécaze 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Draft creates a new draft (unpublished) version of the content. It enables you to draft a revision and preview it before it is published. It doesn't unpublish existing content.

Thanks for the clarification Drew.

What would be the best way to hide/unpublish content and make sure it won't appear on the website (including search results)?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

You could add a checkbox, check for the value of it and redirect to a 404 at the top of your page.

Thank you Rachel, I've ended up with a checkbox to hide an item, and a conditional around the whole template:

<perch:if id="hide" value="true" match="neq">
[...]
<perch:content type="checkbox" id="hide" label="Hide" suppress="true" value="true" divider-before="Visibility" />
</perch:if>

This effectively hides the item on the website and in search results.

To be extra sure, I've added a filter on the page template:

<?php
    perch_collection('Projects', [
    'template'   =>'project.html',
    'filter' => 'hide',
    'match' => 'neq',
    'value' => 'true',
    ]);
?>

Shouldn't toggling the visibility of content be a core feature of Perch? It's very common for clients to prepare some content that they don't want to publish just yet.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It is a core feature - or at least the ability to filter your content however you need it is a core feature.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Abigail - this thread is a year old. If you need support, please start your own thread including the code you are having trouble with so we can help you.