Using Templates in PowerCMS
PowerCMS 2 has a templating feature that adds useful functionality for certain websites. This feature is most commonly used for news websites and blogs and is not expected to be used by all PowerCMS implementations.
The following tutorial explains the process of setting up a template and how you can create new pages based on that template.
NOTE:Unless you have a specific use for a template you should not select the Use as template option for the pages you create in PowerCMS.
What you need to start:
PowerCMS 2 functioning on your live server.
Web Browser (Firefox, Internet Explorer, Safari etc.)
WYSIWYG or Text Editor for minor code changes.
Create the template
The first step in using the PowerCMS template feature, is to create the template that the pages will be based on.
- Signed in as the Super Admin, choose the green + icon from the top of the Content column.
- Enter the name of the template.
For example, 'newsarticle'.
- Select the Use as template checkbox.
- Click OK.
The template is added to PowerCMS like any other page but is distinguished by a different icon.
Add the content areas
Content areas are added to the template just like you would any normal content location (page) in PowerCMS.
- Choose the template from the Contents column.
- Add all the content areas to your template in PowerCMS.
When you or your client adds new pages based on this template, the new pages will have all the same content areas as the template for them to modify to contain their new information.
Apply the Developer Notes
As with a normal Content Location (page) in PowerCMS, you need to add the Developer Notes for each content area of your template, to the PHP page you wish to use for these pages.
NOTE:You will use only one PHP page to display all the pages that are created based on this template. You or your client will be provided with a URL variable that they will append to the PHP page's URL to view the new page's content.
- Select the template from the Content column.
- Click the Developer Notes link for the first content area.
- Highlight the Developer Notes and press Ctrl (Cmd) + C to copy.
- In your preffered editor, open the PHP page you wish to use to display these pages.
- In Code View, place your cursor where you wish this content area's content to display.
- Press Ctrl (Cmd) + V to paste the Developer Notes.
- Repeat this process for all other content areas you have added to your template.
- Save the PHP file and upload to your live server.
Create new dynamic page
When creating a new page based on your template you are not creating a new PHP file on your site. Instead, you are creating a different set of content for the same PHP file. This allows you (or your client) to quickly add new pages from within PowerCMS without having to create new files or enter any code.
Adding pages based on a template in PowerCMS can be performed by any Administrator.
- In PowerCMS, hover your mouse over the template you created and click the green + button that appears.
- Enter a name for the new article/page.
The name should be specific to help you identify the post in PowerCMS.
- Click OK to create the page.
The new page is created as a subpage of the template containing all the content areas of that template.
- In PowerCMS, edit the content areas of the new page as desired.
View the dynamic page
Once you have created a new page based on a template in PowerCMS, you can quickly view that page by obtaining the URL variable that is to be added to the end of the template PHP page URL.
NOTE:This URL variable will only work on the page where the Developer Notes for the template have been added. If you are handing this off to a client that is expected to create new pages using this feature, you should make sure that the client knows which page this URL variable should be added to.
Locating the URL Variable for the Super Admin
- In PowerCMS, select the new page from the Content Column
- Click the Developer Notes link for any of the content areas of that page.
- Highlight the URL variable provided in the Display this content without this code... section.
- Press Ctrl (Cmd) + C to copy.
- In your browser, navigate to the page that the template's Developer Notes have been applied to.
- Place your cursor at the end of the URL in the Address bar, and press Ctrl (Cmd) + V to paste.
The URL will look something like http://mysite.com/template.php?article=4
- Press Go or Enter to navigate to this page.
The content will update on the page to reflect what was added to the new page.
Locating the URL Variable for the regular Admins
- In PowerCMS, select the new page from the Content Column
- Click the Create Link option for any of the content areas of that page.
- Highlight the URL variable and press Ctrl (Cmd) + C to copy.
- In your browser, navigate to the page that the template's Developer Notes have been applied to.
- Place your cursor at the end of the URL in the Address bar, and press Ctrl (Cmd) + V to paste.
The URL will look something like http://mysite.com/template.php?article=4
- Press Go or Enter to navigate to this page.
The content will update on the page to reflect what was added to the new page.
What to do next...
Now that you have the URL to use for your new page you can create links throughout your site to that new page you just created. You can insert the link directly within the HTML Editor for any content area in the CMS.
Also...
The PHP file that you applied the Developer Notes to will automatically display the most recent page's content that was added to the CMS. This way, you can easily use that page as a "Most Recent Article" or "Newest Blog Post" without having to update the link everytime you add a new page.
Last Updated:
October 27, 2010