Forum

Thread tagged as: Question

New Page Workflow with "Draft" Feature

Hullo all!

First: love the new forums. Looking forward to seeing a good thing get even better!

On to my question:

When giving clients the ability to add new pages to a Perch site, is there any way to modify the workflow such that the newly-added page is not "live" without another button-press of some sort?

The reason would be to avoid "partially-published" pages from appearing on a live site. If the new page had an explicit "put me on the website now" feature, that might allow clients to build the page a little more slowly, rather than having to be ready to dump most of their content into the regions immediately after clicking "Add new page".

I can currently hack this in via a select box in a region that controls CSS visibility and a NOINDEX clause, but that's sketchy at best, brutal for screen-readers, and not something I want to use in a live environment.

Any thoughts from Drew or other Perchers on how they get around this, or perhaps I'm missing something super obvious?

Thanks!

Richard Terrick

Richard Terrick 3 points

  • 7 years ago

I recently asked a similar question, but that was more around being able to set a published date for content - that said, the solution may help you.

The solution I was given, though not yet put into practice yet was to use a custom field in the edit form, to set a published status (I'm guessing a simple drop down selector would suffice) and then use content_custom on the page and navigation templates to filter out and only show content where published is set to true.

Might help? Though I agree, a built in solution would be much nicer :D

Haydn – thanks!

That's a much more robust solution than my hack, for sure, and although it doesn't stop the page from being indexed, hopefully there isn't days or weeks of time between the client clicking "add page" and marking it as "published", so this should cover 99% of the cases.

I wonder if a select field in the page attributes template would work along those same lines? Seems like a logical place for such an option for my purposes, rather than in one of the content regions. Can't remember if content_custom can grab the page attributes or not.

Anyway, thanks again - gives me something to try. The question is somewhat more of a theoretical one than a this-project-is-going-nowhere-until-it's-resolved one, but when I test I'll report back. If there is a more "baked-in" option, I'd love to hear it. Cheers!

Drew McLellan

Drew McLellan 2638 points
Perch Support

How about adding a Publish field to the page attributes?

That's exactly the plan – thanks to both Haydn and Drew. If I could mark both answers as right I would, but I'm giving the point to Haydn this time. :-)

Thought I'd follow-up with the implemented solution – turned out to be as easy as a checkbox on the Page Details section in the admin.

Page Attributes – A single checkbox in the page attributes lets the admin publish a page (or not):

<perch:pages id="publish_page" label="Publish Page?" type="checkbox" value="1" suppress="true" />

HTML Page – All we need is a plain-old perch_pages_navigation call (you'd likely want to pass in a template, at least):

<?php perch_pages_navigation(); ?>

Navigation Template – Again, nothing fancy here EXCEPT the addition of one more perch:if tag to check against the value in the page attributes checkbox (thanks to this article for the tip). If it's not checked, it's not displayed:

<perch:before>
<ul>
</perch:before>
    <perch:if exists="publish_page" value="1">
        <li<perch:if exists="current_page"> class="selected"</perch:if><perch:if exists="ancestor_page"> class="ancestor"</perch:if>><a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a><perch:pages id="subitems" encode="false" /></li>
    </perch:if>
<perch:after>
</ul>
</perch:after>

Anyway, hope this helps someone else!