PowerCMS's templating feature is incredibly useful if you want to hand a site over to someone else and allow them to make their own pages from an existing CMS template.
In this tutorial we'll help you create new pages in PowerCMS, and display those pages on your website. We'll also walk you through the steps to create functionality on your website to automatically display the pages you created in the CMS.
NOTE: This Tutorial teaches you how to make a theoretical dog park blog, but you can change it to anything you want; a cat park, a bird park, a human park, or even something that isn't a park at all.
- Dreamweaver
- A PowerCMS site set up within Dreamweaver
- Web Browser (Chrome, Firefox, Internet Explorer, etc.)
The first step in using the using a PowerCMS Template to create new pages, is to create the template that the pages will be based on.
- Signed into your CMS admin with the Super Admin account
- Choose the green icon from the top of the Content column.
- Enter the name of the template.
For example, 'BlogPosts'.
- Select the Use as template checkbox.
- Click ADD.
The template is added to PowerCMS like any other page but is distinguished by a different icon.
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.
- Click the Add Content button located above the existing content areas.
- On the Insert New Content page, click in the Content Area field and enter the content area name.
For example, 'BlogPostTitle'.
- Click the beautiful Insert button.
You've now successfully created a template for use in PowerCMS.
New pages created under a template will have all the same content areas as the template, but their own unique values for those content areas, allowing you to create multiple pages with the same basic layout, but differing content.
- Click the green button to the right of your template name.
- On the Add New Page from Template dialog, click in the Content Name field and enter the page name.
For example, 'Dog Park'.
- Click the Add button.
This step will populate the newly created content page with some much needed content.
- Click the Edit link to the right of your title content area name.
- On the Currently editing page, click within the content text editor.
- Enter the Title for your new page.
For example, 'New Dog Park Opened'.
- Click the Update button to apply the update.
- Click the Edit link to the right of your content area name.
- On the Currently editing page, click within the content text editor.
- There will be some default text in this box, so clear the existing data from the box.
- Enter some text for your first post.
For example, 'Hello World!' is a classy starter. Lorem Ipsum also looks nice.
- Click the Update button to apply the update.
- Repeat steps 1-9 with different content each time to create 4 pages of content to use later on.
Next up, we're going to show you how to create a results page. This page will dynamically pull all the post titles in from the CMS and display them in a list. Later, we'll make each post title a link to a second page that will display the post's content.
- In Dreamweaver, make sure your files list is set to the same PHP site we're using for PowerCMS.
- Click File > New in the menu.
- In the New Document window, select the Page from Template tab along the left hand side.
- Select the site used for PowerCMS
- Within the Template for Site list, select the template you are using for your site's design.
- Click Create.
- Save the new page to your site by clicking File > Save As.
- Enter the name for the page in the Save As dialog.
For example, 'blog-results.php'.
- Click the Save button.
Now we need to add a recordset to the page so we can pull the PowerCMS content from the database.
- Click Insert > Data Objects > Recordset.
The Recordset dialog might default to the Simple layout. You will need to switch to the advanced layout by clicking the Advanced... button on the right side of the dialog.
- Enter the name of your Recordset.
For example, 'BlogRS'.
- Copy the following code and paste it into the SQL field on the Recordset dialog.
SELECT C2.ContentGroup, C2.ContentPageSetOrder
FROM pcms2_contents AS C1 LEFT OUTER JOIN pcms2_contents AS C2 ON C2.ContentPagesetParentID = C1.ContentID
WHERE C1.ContentGroup = 'BlogPosts'
AND C2.ContentPageSetOrder IS NOT NULL
GROUP BY C2.ContentPageSetOrder
ORDER BY C2.ContentPageSetOrder DESC
- Find the following line in the SQL, and change the text in the single quotes ( in this case it is 'BlogPosts' ) to the name of your PowerCMS template that your set up earlier.
WHERE C1.ContentGroup = 'BlogPosts'
- Now click OK to add your shiny new Recordset to the page.
- The next step in our wonderful journey takes us to adding the CMS code to our page.
- Head back to the PowerCMS admin and select the template we created earlier.
- Click the Developer Notes link for the title content area ( which in our case is 'BlogPostTitle' ).
- Copy the code presented at the bottom of the resulting dialog.
- Click Done.
- Return to Dreamweaver, and view the results page.
- Switch to code view for the page, if not already selected.
- Find the content area of the page, and paste the copied code from step 17 into the content area.
- Now, we need to edit this code to display just the titles, so you need to change the following code:
- to say
false, $row_BlogRS['ContentPageSetOrder'] );
$row_BlogRS is correct if you used our naming examples, but it will be named differently if you named your recordset something else. Change "BlogRS" to the name you used for your recordset if you chose another name.
- Click File > Save to save your progress, and preview the page in a browser.
Notice the title of the last content page you added in PowerCMS is shown, but not the others. Now we need to make the PowerCMS area a repeat region to show all titles of blog posts instead of just one.
- Back in Dreamweaver, switch to design view for the results page we've been working on.
- Select the PHP tag for the PowerCMS code we just added to select the entire PHP region.
- Click Insert > Data Objects > Repeat Region.
- In the resulting dialog, ensure the Recordset selected is the one we created earlier.
- Under the Show option, select All.
- Click OK to apply the Repeat Region.
- Click File > Save to save your progress, and preview the page in a browser.
Now all of your content pages are accounted for!
The time has come to create our details page to display the actual content of each of the posts we've created in PowerCMS. This page will dynamically pull all the post titles and content for the content that was selected on the results page.
- In Dreamweaver, make sure your files list is set to the same PHP site we're using for PowerCMS.
- Click File > New in the menu.
- In the New Document window, select the Page from Template tab along the left hand side.
- Select the site used for PowerCMS
- Within the Template for Site list, select the template you are using for your site's design.
- Click Create.
- Save the new page to your site by clicking File > Save As.
- Enter the name for the page in the Save As dialog.
For example, 'blog-details.php'.
- Click the Save button.
- Now return to the results page we created earlier.
- View the Bindings panel. If the panel is not visible, it can be access by clicking Window > Bindings.
- Select the recordset that we created on the results page.
- Click the options button in the Bindings panel ( it looks like a little black arrow pointing down with 4 lines by it ), and click Copy to copy the recordset.
- Return to the details page.
- In the Bindings panel for the details page, click the options button ( again, it looks like a little black arrow pointing down with 4 lines by it ), and click Paste to paste the recordset from the results page.
You've just copied the recordset over from the results page. It needs to be edited to work on the details page, and we're going to do that now.
- Double click on the recordset in the Bindings panel.
- Now, we need to edit the SQL statement to only pick the blog post that was selected, so you need to change the following code in the SQL field:
AND C2.ContentPageSetOrder IS NOT NULL
- to say
AND C2.ContentPageSetOrder = post
"post" is a variable that holds the selected post from the results page so the SQL query only pulls the correct data.
- Click the button above the variable field on the Recordset dialog.
- On the resulting dialog, enter post in the name field, exactly as it was typed in the SQL query. It needs to match perfectly, or an error will occur.
- Change the Default value field to -1.
- Enter $_GET["ID"] into the Runtime value field.
- Click OK to close the variable dialog and add the variable.
- Click OK again to update the Recordset.
Now we need to add the CMS code for the title and content areas of our CMS content pages to the details page.
- Back we go to the PowerCMS admin and select the template we created earlier.
- Click the Developer Notes link for the title content area ( which in our case is 'BlogPostTitle' ).
- Copy the code presented at the bottom of the resulting dialog.
- Click Done.
- Return to Dreamweaver, and view the details page.
- Switch to code view for the page, if not already selected.
- Find the content area of the page, and paste the copied code from step 25 into the content area within its own <p> tags.
- Once more unto the breach, dear friends, of the PowerCMS admin and select the template we created earlier.
- Click the Developer Notes link for the main content area ( which in our case is simply called 'Content' ).
- Copy the code presented at the bottom of the resulting dialog.
- Click Done.
- Return to Dreamweaver, and view the details page.
- Switch to code view for the page, if not already selected.
- Find the content area of the page, and paste the copied code from step 33 into the content area within its own <p> tags just under the title <p> tags.
- For both of these freshly pasted CMS content areas, we need to edit the code to show the selected results, so like we did before, change the following code sample:
- to say
false, $row_BlogRS['ContentPageSetOrder'] );
Like before, $row_BlogRS is correct if you used our naming examples, but it will be named differently if you named your recordset something else. Change "BlogRS" to the name you used for your recordset if you chose another name.
- Click File > Save to save your progress.
We now need to edit the results page to turn each CMS content page's title to be a link to the detail page, and make the detail page show the respective content to the selected page.
- Return to the results page we created earlier.
- In code view, set your cursor just before the beginning of the CMS PHP code chunk.
- Enter the following code before the code chunk to make the link and set a URL variable to the ID:
<a href="blog-details.php?ID=<?php echo $row_BlogRS['ContentPageSetOrder']; ?>">
Once again, the details page name, the ID variable, and the $row_BlogRS variable names are correct if you used our naming examples, but it will be named differently if you named them something else. If you used another name, you will need to change the code accordingly.
- Add a closing </a> at the end of the CMS PHP code chunk to close off the link.
- Click File > Save to save your progress, and preview the page in a browser.
Now all of your content pages are accounted for!
Now we are going to add pagination to your results page to make it cleaner if you get a huge number of posts to this nice blog of yours. It's a nice feature to give your site that modern look, and it's pretty easy to implement. I have faith you can do it.
- In Dreamweaver, view the results page.
- View the Server Behaviors panel. If the panel is not visible, it can be access by clicking Window > Server Behaviors.
- Double click on the Repeat Region server behavior we created earlier on to edit it.
- For this example we're only going to show 2 posts per page, so change the Show field to X options at a time, and change the amount shown to 2.
- Click the OK button to update the repeat region.
- Click Insert > Data Objects > Recordset Paging > Recordset Navigation Bar.
- Ensure the Recordset option is set to the recordset we created on this page ( in this case it is 'BlogRS' ).
- Make sure the Display using option is set to Text
- Click OK to add the navigation to the recordset.
- Click File > Save to save your progress, and preview the page in a browser.
Lastly, we are going to create a page that allows you to view the details of a blog post, but also allows you to paginate between the posts one at a time.
- In Dreamweaver, make sure your files list is set to the same PHP site we're using for PowerCMS.
- Click File > New in the menu.
- In the New Document window, select the Page from Template tab along the left hand side.
- Select the site used for PowerCMS
- Within the Template for Site list, select the template you are using for your site's design.
- Click Create.
- Save the new page to your site by clicking File > Save As.
- Enter the name for the page in the Save As dialog.
For example, 'blog-all.php'.
- Click the Save button.
- Now return to the results page we created earlier.
- View the Bindings panel. If the panel is not visible, it can be access by clicking Window > Bindings.
- Select the recordset that we created on the results page.
- Click the options button in the Bindings panel ( it looks like a little black arrow pointing down with 4 lines by it ), and click Copy to copy the recordset.
- Return to the blog-all page.
- In the Bindings panel for the blog-all page, click the options button ( again, it looks like a little black arrow pointing down with 4 lines by it ), and click Paste to paste the recordset from the results page.
- Head to the PowerCMS admin and select the template we created earlier.
- Click the Developer Notes link for the title content area ( which in our case is 'BlogPostTitle' ).
- Copy the code presented at the bottom of the resulting dialog.
- Click Done.
- Return to Dreamweaver, and view the blog-all page.
- Switch to code view for the page, if not already selected.
- Just like you did for the other pages, find the content area of the page, and paste the copied code from step 18 into the content area within its own <p> tags.
- For the last time, let's go to the PowerCMS admin and select the template we created earlier.
- Click the Developer Notes link for the main content area ( which in our case is simply called 'Content' ).
- Copy the code presented at the bottom of the resulting dialog.
- Click Done.
- Return to Dreamweaver, and view the blog-all page.
- Switch to code view for the page, if not already selected.
- Find the content area of the page, and paste the copied code from step 25 into the content area within its own <p> tags just under the title <p> tags.
- To spruce up these CMS content areas, we need to edit the code to show the selected results, so like we did before, change the following code sample:
- to say
false, $row_BlogRS['ContentPageSetOrder'] );
Like before, $row_BlogRS is correct if you used our naming examples, but it will be named differently if you named your recordset something else. Change "BlogRS" to the name you used for your recordset if you chose another name.
- Now select all the CMS PHP code you inserted into the page.
- Click Insert > Data Objects > Repeat Region.
- In the resulting dialog, ensure the Recordset selected is the one we created earlier.
- Under the Show option, we only want to show one record at a time, so change the Show field to X options at a time, and change the amount shown to 1.
- Click OK to apply the Repeat Region.
- Click Insert > Data Objects > Recordset Paging > Recordset Navigation Bar.
- Ensure the Recordset option is set to the recordset we created on this page ( in this case it is 'BlogRS' ).
- Make sure the Display using option is set to Text
- Click OK to add the navigation to the recordset.
- Click File > Save to save your progress, and preview the page in a browser.
Well done! you have now created a basic dog park blog for your site! Now you can create more normal blogs, or create the cat park blog you've always wanted.
For a greater challenge, try adding more content areas to your details page, or creating a search feature for your results page!
Michele: 10 Years, 6 Months, 1 Week, 4 Days, 14 Hours, 44 Minutes ago
My client wants to be able to create a new page (newpage.php) from a template that I set up. Is that possible in PowerCMS?
Team WebAssist: 10 Years, 6 Months, 1 Week, 3 Days, 19 Hours, 42 Minutes ago
Yes, this tutorial demonstrates how to get that set up in PowerCMS and have any new pages automatically add to the site when your client sets them up.
And this tutorial: http://www.webassist.com/tutorials/Use-templates-in-PowerCMS allows your client to get the page set up and the CMS admin to manually add the page where they want in the site.