1 | # Carrington CMS Theme Framework for WordPress
|
---|
2 | http://carringtontheme.com
|
---|
3 |
|
---|
4 | by Crowd Favorite
|
---|
5 | http://crowdfavorite.com
|
---|
6 |
|
---|
7 | Released under the GPL license
|
---|
8 | http://www.opensource.org/licenses/gpl-license.php
|
---|
9 |
|
---|
10 | ---
|
---|
11 |
|
---|
12 | ## What is Carrington?
|
---|
13 |
|
---|
14 | 1. A collection of elegant, high-end WordPress themes for end-users.
|
---|
15 | 2. A designer and developer friendly CMS theme framework for WordPress.
|
---|
16 | 3. A set of best practices for theme organization.
|
---|
17 |
|
---|
18 |
|
---|
19 | ## Basic Framework Concept
|
---|
20 |
|
---|
21 | Carrington is a CMS theme framework that virtually eliminates the need for custom conditional code in themes. Instead, template naming conventions along with the Carrington engine replace the need for this conditional code.
|
---|
22 |
|
---|
23 | Theme functionality is broken up into thoughtfully crafted abstractions to enable customizations at different levels (the loop, the post/page content, comments, etc.) and the Carrington engine chooses which template to be used for each segment of the theme.
|
---|
24 |
|
---|
25 | The abstractions and supported template types are designed to easily handle most of the customization scenarios we commonly see without the need to write custom code to use them.
|
---|
26 |
|
---|
27 |
|
---|
28 | ## Context and Templates
|
---|
29 |
|
---|
30 | WordPress provides a number of functions to help you determine what type of view a theme is showing. These include:
|
---|
31 |
|
---|
32 | - `is_home()`
|
---|
33 | - `is_single()`
|
---|
34 | - `is_page()`
|
---|
35 | - `is_archive()`
|
---|
36 | - `in_category()`
|
---|
37 | - etc.
|
---|
38 |
|
---|
39 | Carrington abstracts these to deduce a "context" that is used when selecting a template. There are three context types used by the Carrington framework:
|
---|
40 |
|
---|
41 | 1. Comment (dirs: comment)
|
---|
42 | 2. Post (dirs: content, excerpt)
|
---|
43 | 3. General (dirs: attachment, comments, footer, header, loop, posts, sidebar, single)
|
---|
44 |
|
---|
45 | Each directory implements one of these contexts for selecting the appropriate template to use. Templates are used in page views based on how they match the given context(s) for the overall page and the specific pieces of content being displayed.
|
---|
46 |
|
---|
47 | Read about the options available in each directory in the README file for that directory.
|
---|
48 |
|
---|
49 | Note: "default.php" is a supported default file name for all directories, however we have found in real world usage that {dirname}-default.php is a preferable naming system. When you have a half-dozen "default.php" files open in your favorite text editor, telling them apart in the file list can be more difficult than it should be.
|
---|
50 |
|
---|
51 |
|
---|
52 | ## Theme Organization
|
---|
53 |
|
---|
54 | WordPress themes generally have a file structure similar to this:
|
---|
55 |
|
---|
56 | - 404.php
|
---|
57 | - archive.php
|
---|
58 | - archives.php
|
---|
59 | - [...]
|
---|
60 | - sidebar.php
|
---|
61 | - single.php
|
---|
62 | - style.css
|
---|
63 |
|
---|
64 | While this organization works well in many instances, it doesn't well support the concept of atomic elements that are combined to create a theme. For example, a representation of just a post's content, or just a comment, is not represented here.
|
---|
65 |
|
---|
66 | Carrington respects the supported WordPress file naming conventions (for example `get_header()` will still work), but eschews them in favor of an organizational structure that better suits the abstraction and customization commonly needed for a WordPress theme.
|
---|
67 |
|
---|
68 | Template files are layered into each other using the following basic approach:
|
---|
69 |
|
---|
70 | 1. top level templates that include
|
---|
71 | 2. common elements like a header, footer and sidebar along with a
|
---|
72 | 3. loop that includes
|
---|
73 | 4. atomic post/page content or excerpt templates and, where appropriate, a
|
---|
74 | 5. comments area template that includes
|
---|
75 | 6. atomic template for comments and a
|
---|
76 | 7. template for the comment form
|
---|
77 |
|
---|
78 |
|
---|
79 | ## Actions and Filters
|
---|
80 |
|
---|
81 | The Carrington core is a theme framework, not a parent/child theme system. It includes a core set of functions that enable the override template hierarchy. These functions include actions and filters where appropriate so that their functionality can be customized and overridden as needed. These actions and filters use the same hook and filter system used in the WordPress core.
|
---|
82 |
|
---|
83 |
|
---|
84 | ### Filters
|
---|
85 |
|
---|
86 | - `cfct_context` - allows you to apply filters to the return value of the `cfct_context()` function; the function that checks to see what posts file, loop file, etc. to show.
|
---|
87 | - `cfct_filename` - filter the output of the `cfct_filename()` function.
|
---|
88 | - `cfct_general_match_order` - set the order in which general templates are chosen (make it check for a cat-general template ahead of a cat-news template, etc.).
|
---|
89 | - `cfct_choose_general_template` - filter the output of the `cfct_choose_general_template()` function (the selected general template).
|
---|
90 | - `cfct_single_match_order` - set the order in which single and content templates are chosen (make it check for author templates ahead of meta template, etc.).
|
---|
91 | - `cfct_choose_single_template` - filter the output of the `cfct_choose_single_template()` function (the selected single template).
|
---|
92 | - `cfct_choose_content_template` - filter the output of the `cfct_choose_content_template()` function (the selected content template).
|
---|
93 | - `cfct_comment_match_order` - set the order in which content templates are chosen (make it check for role templates ahead of user templates, etc.).
|
---|
94 | - `cfct_choose_comment_template` - filter the output of the `cfct_choose_comment_template()` function (the selected comment template).
|
---|
95 | - `cfct_meta_templates` - filter the return value of the `cfct_meta_templates()` function (change the list of files returned).
|
---|
96 | - `cfct_cat_templates` - filter the return value of the `cfct_cat_templates()` function (change the list of files returned).
|
---|
97 | - `cfct_tag_templates` - filter the return value of the `cfct_tag_templates()` function (change the list of files returned).
|
---|
98 | - `cfct_author_templates` - filter the return value of the `cfct_author_templates()` function (change the list of files returned).
|
---|
99 | - `cfct_role_templates` - filter the return value of the `cfct_role_templates()` function (change the list of files returned).
|
---|
100 | - `cfct_parent_templates` - filter the return value of the `cfct_role_templates()` function (change the list of files returned).
|
---|
101 | - `cfct_single_templates` - filter the return value of the `cfct_parent_templates()` function (change the list of files returned).
|
---|
102 | - `cfct_comment_templates` - filter the return value of the `cfct_single_templates()` function (change the list of files returned).
|
---|
103 | `cfct_post_gallery_columns` - set the number of columns to show in the gallery.
|
---|
104 | `gallery_style` - retained from the WP function code copied in and altered for gallery display.
|
---|
105 | `cfct_option_defaults` - allows you to set defaults (alter/add/etc.) for Carrington options.
|
---|
106 |
|
---|
107 |
|
---|
108 | ### Actions
|
---|
109 |
|
---|
110 | - `cfct_settings_form` - allows you to add your own fields to the Carrington Settings form (left for compatibility` - recommend using _top and _bottom as needed instead of this).
|
---|
111 | - `cfct_settings_form_top` - allows you to add your own fields at the top of the Carrington Settings form.
|
---|
112 | - `cfct_settings_form_bottom` - allows you to add your own fields at the bottom of the Carrington Settings form.
|
---|
113 | - `cfct_settings_form_after` - allows you to add your content after the Carrington Settings form. Useful if you want to add a second form to the page, or some other content.
|
---|
114 | - `cfct_update_settings` - allows you to take action when the Carrington settings are being saved (perhaps to also save fields you've added in the `cfct_settings_form` action).
|
---|
115 |
|
---|
116 |
|
---|
117 | ## Plugins
|
---|
118 |
|
---|
119 | Any .php files in the *plugins/* directory will be automatically loaded by Carrington. This is a great way to bundle in custom functions or to hook into Carrington's actions or filters and be able to distribute everything as a single theme package.
|
---|
120 |
|
---|
121 | ---
|
---|
122 |
|
---|
123 | ## Tips
|
---|
124 |
|
---|
125 | There is very minor extra processing associated with the file system and context checks that Carrington requires. This overhead is virtually unnoticeable, however the use of a caching plugin is recommended as a general best practice.
|
---|