Template for static pages

32 views
Skip to first unread message

Daniel Suarez

unread,
Apr 10, 2010, 8:25:03 PM4/10/10
to Carrington CMS Theme Framework for WordPress
After reading everything I was finally able to understand how
Carrington works. It really is a great tool. Thank you so much for
this.

My question is, how do I target an specific static page with
carrington. For example, let's say I have a services page and I wanted
to have a different sidebar. Would the sidebar be sidebar/
services.php?

Thanks so much in advance.

Kai Pan

unread,
Apr 11, 2010, 3:52:19 AM4/11/10
to carrington...@googlegroups.com
The Carrington Framework supports a page.php template in the sidebar folder. This allows you to specify a specific sidebar to appear whenever WP is showing a "Page". If you just want one common sidebar for all Pages that is different from other parts of the website (like on a single post page or category archive page, etc.), then just create/modify a page.php file in the sidebar folder.

If you want a different sidebar for different Pages, then it'll be a bit more complicated. In that scenario, you'll probably want to not call the sidebar folder at all and instead custom code different sidebars into page templates that you'd put in the pages folder. Be sure to read the instructions in that folder to make sure it works though.



--
To unsubscribe, reply using "remove me" as the subject.

Daniel Suarez

unread,
Apr 11, 2010, 4:17:39 PM4/11/10
to Carrington CMS Theme Framework for WordPress
Ohh, ok, so I have to create templates for each page that I want. For
example portfolio.php (have some samples in the sidebar
services.php (have a list of the services as a sub nav in the
sidebar) team.php( people in the sidebar)

So for those pages, I wouldn't have to call the sidebar directory, but
instead hard code what I want on each one, right?

Thanks so much!

Kai Pan

unread,
Apr 11, 2010, 8:22:59 PM4/11/10
to carrington...@googlegroups.com
I think you'd have to create page-templates in the /pages/ folder with a page-template in the parent folder that points to the actual page-template in the /pages folder as well (2 files so far, but only to maintain consistency with how Carrington organizes itself). Then, when you make the page in WP, you select the appropriate page template (which is a normal WP feature/function/ability).

To make it extra clear:
1. WP page is directed to use a specific page template that appears in the Carrington parent folder.
2. Parent folder includes a placeholder page-template that simply forwards into the /pages/ subfolder.
3. Inside the /pages/ subfolder is the actual page-template with all of the code you want to use to make that page unique.

And, of course, you'd probably create the above 3 in REVERSE order.

On the page-template IN the subfolder, you'd just hardcode everything that the framework doesn't handle. So, for example, if your header is common with other parts of the website, you could continue calling it (and it would use either the page.php or header-default.php etc. template in the /header/ subfolder). Likewise with the footer. But since you want different sidebars for each different page, you'd have to hardcode the differences either directly in the page-template inside the /pages/ subfolder

OR, if you want to stick with the Carrington idea of organization, maybe put the different sidebar code inside the /sidebar/ subfolder knowing that it won't automatically get called under any "contexts" without you adding something like:

<?php include (TEMPLATEPATH . "../sidebar/sidebar-for-services-page.php"); ?>

...IN the page-template IN the /pages/ subfolder to manually call it.

The more you atomize your code and set up linking like the above, the less duplicate code you have (allowing you to only make changes to one shared file instead of multiple files that include the same element). Only problem is, you kinda have to keep track of the web you've spun. There's probably also a bit of overhead involved in having your server access different templates to build each page but as Carrington says, it isn't too much and you should be using caching anyway.

Hope this helps you understand Carrington as I do! Cheers.

Daniel Suarez

unread,
Apr 12, 2010, 11:03:50 AM4/12/10
to Carrington CMS Theme Framework for WordPress
Gottcha! I think the example you're giving is great. So for services,
I would have a file under sidebar/sidebar-for-services-page.php, and
in the pages/services.php template I would have the include code for
the side bar. So I would have to have one sidebar file and one page
file template for each page that is going to have a unique sidebar,
correct?

Last question pretty dumb I think. How does Carrington know what page
am I talking about. Is it just by calling it services.php, and have
the tittle in wordpress being services? Or how do I target it exactly?

Thanks again so much for your time and help :)

Kai Pan

unread,
Apr 12, 2010, 11:12:24 AM4/12/10
to carrington...@googlegroups.com
Hey Daniel,

Actually three files. There's a readme in the pages directory that explains it. For example:

1. page-services.php - this would just be coded to include #2.
2. /pages/page-services.php, this would be coded to include #3.
3. /sidebar/sidebar-for-page-services.php - this would be where the custom sidebar code for specifically this page goes.

You can use whatever naming convention you want though. The above is just one way I'd name it.

You can actually just have #2 reside in the parent directory if you wanted, but Carrington encourages you to organize your files into subfolders.

Alex King

unread,
Apr 12, 2010, 5:14:56 PM4/12/10
to carrington...@googlegroups.com
A benefit of using:

cfct_template_file('sidebar', 'sidebar-filename')

instead of include(...) is that setting debug on will show the file
path banner for the sidebar file.

Kai Pan

unread,
Apr 12, 2010, 10:52:11 PM4/12/10
to carrington...@googlegroups.com
Word, I better start using that.
Reply all
Reply to author
Forward
0 new messages