Using Snippets to Automate Rotating Text Bites
This process can be used to automate the updating of a small snippet of text within a page, without the editor of that page having to make changes manually and apply for workflow at each step. It requires Snippets turned on, and knowing in advance what you need to update the text with, and when.
Background
This procedure is used in Selwyn to update the page that lists the proposed changes to our District Plan. Almost all of our content goes through a 2-step workflow before being permitted to go Live on the site. This means every time an editor wants to make a small change, such as changing a plan change from showing “Submissions invited until Feb 5” to showing “Submissions now closed”, it has to go through this process. We can use snippets to fully automate this for each Plan Change.
The changes go through several stages, from seeking submissions through to hearings and a final decision. The status of each change displays on the page after the change name, and in red bold text. An example listing on the page looks like this (where the first few words are a link to more info and the bold text at the end is usually red) -
Plan Change 13: For demonstration - Submissions invited until June 1
We can use snippets to automate the text bites at the end if we know in advance what we want to say, and when.
You have to have already turned on snippets on your site and created an area to contain them.
For the purposes of this tutorial, we’ll assume we have plan change 13, that has submissions open from now until June 1 at 5pm, and then after that displays that there is a hearing on June 17, and then after the hearing displays “Pending decision”.
Creating the Snippets
Snippets are stored on our site outside of our workflow. They do not go through the approvals process. Since the only content here is what date/time certain things close, there is no need for workflow.
In the folder where snippets are kept, I create three new standard pages, one for each phase of the text bite update. They're named pc13-subs, pc13-hearing, and pc13-decision. For each, I need to name the DIV the same so I know what to select in the snippet drop-down in the WYSIWYG editor later. I also need to set each DIV’s Presentation and Content Type both to “Raw HTML”.
Then I need to create the content with the HTML tags to generate it how I want it to look. In this case we want red text and bold, so it looks like this:
<b><span style="color: rgb(255,0,0);">Submissions invited until 5pm, June 1st</span></b>
I create the other two snippet page contents similarly, each with their own name and message.
Future Statuses
Each of the snippets now requires its own special Status and Future Status settings.
Since the submissions are open from now, I want the pc13-subs to be Live immediately. Then I want that one to be Archive on 1 June at 5pm.
I want pc13-hearing to remain Under Construction for now, but become Live at 5pm on June 1st, and then become Archive at 8pm on June 17th.
Lastly, I want to set pc13-decision to remain Under Construction for now, but become Live at 8pm on June 17th.
Now we’re ready to insert the snippets into the page.
Editing the Page, and Workflow
I can now edit the page listing our Plan Changes and add the details for Plan Change 13. When I have typed the name, instead of typing “Submissions are open” or similar manually, I simply add all three snippets from the drop-down menu, one after the other, without spaces.
Plan Change 13: For Demonstration - %globals_snippet_25608_pc13-subs%%globals_snippet_25612_pc13-hearing%%globals_snippet_25616_pc13-decision%
Note that there are no spaces between the snippets. Since only one is going to show at any time anyway, if there were spaces, there would eventually be 2-3 blank spaces between “Demonstration -” and the currently showing snippet text.
The page can now go through the workflow system and be approved. Obviously this does not permit the content of the snippets to be part of that approval, but once again, as we are only dealing with what dates the submissions/hearing happen, that is not necessary.
Viewing
Because only the one snippet is Live at any one time, the public users viewing the site only see that snippet displayed. They will only see “Submissions invited until 5pm” until 5pm on June 1st, only see “Hearing scheduled for June 17th” until 8pm June 17th, and only see “Pending decision” after that. All of these changes are entirely automated by the Future Statuses set earlier on and do not require user input at those times.
Notes
Obviously you can add as many steps as you like. I recommend creating the snippets for as many steps as you will need, even if you don’t know the content yet. Eg if you don’t know what date the hearing is, create the snippet as a blank page now anyway, so that it can still be selected on the page contents and the page can go through workflow. When you do find out the date, you then need only to edit the snippet and create the Future Status for it at that point - the content on the page will still display it without needing any further workflow. If you had not created the snippet at all, you’d have to add it to the page and go through workflow again if you create it after the initial changes.
Tutorial Feedback
There is currently 1 comments.
Thanks Deb!
Firstly. I really value your contribution. Thank you so much for adding this tutorial. We hope to see more of them really soon?
On that note, using snippets for text bites is something I hadn't even considered before. It's been a while since I touched snippets as I was always warned there might be impact on the system (this was around 3.12), but I'm sure there has been loads of improvements to the content type.
I'm pretty inspired now to relook at snippets now in development. So also thanks for that!
Add Your Feedback
You must be logged in to leave a comment. You can sign-up for free!
