Slides from Documenting ExpressionEngine from the EngineSummit 2. Discuss the need and approaches to building developer-focused documentation for EE sites.
Environments mysite.com is running in 4 environments. Local copies are on each independent developer's computer. There is a private Development and private Staging environment and a public Production environment. +*Local*+ * Specific to each developer. * Developers are encouraged to run the latest stable versions of PHP and MySQL +*Development*+ * Located at dev.mysite.com * PHP version 5.2.14 * MySQL version 5.0.84 * Apache 2.2.17 +*Staging*+ * Located at staging.mysite.com * PHP version 5.3.2 * MySQL version 5.0.91 * Apache 2.2.17
previous slide) +*Production*+ * Located at mysite.com * PHP version 5.3.2 * MySQL version 5.0.91 * Apache 2.2.17 h3. Cross-environment config.php This site uses the 3rd Party NSM Config Bootstrap by Leevi Graham of Newism. You can find more information on that multi-environment approach "here":http://expressionengine-addons.com/nsm-config- bootstrap Included in the config_bootstrap.php file we also set the path for the 3rd Party plugin "ED ImageResizer":http://github.com/erskinedesign/ED-Imageresizer This may also be helpful for creating a multi-server environment config.php base file: http:// eeinsider.com/articles/multi-server-setup-for-ee-2/
on the front end ‣ How a Channel uses Categories ‣ Are the Categories shared across any Channels? ‣ Does any Channel use multiple Categories? ‣ How Status Groups are used ‣ Are you allowing content “previews” with Statuses? ‣ Any other non-standard uses? CHANNELS & RELATED GROUPS 26
h2. Channels & Related Groups Our site currently has 2 Channels using a total of 1 Category Group. Each Channel has its own Custom Field Group. Every Channel uses the default Status Group. +*Pages*+ This Channel is for our site's static content. It houses things like About Us and Contact. * No Categories are used * The primary Template used for this Channel's content is site/_pages * Default Status Groups is used * 3 Custom Fields are used ** page_extra_meta (Textarea, not required, searchable, no formatting, using Textarea so content manager can input multiple full meta tags since they know how) ** page_banner (Text Input, not required, not searchable, no formatting, uses file chooser) ** page_content (Textarea, required, searchable, XHTML formatting) The 3rd Party Add-on "Structure":http://buildwithstructure.com is in large use for our Pages Channel. We use it to build the heirarchy of Pages and also the HTML Titles, Menus & Breadcrumbs on the front-end. Pages are primarily run through the template site/_pages (configurable per page and within the Structure settings). There are a few pages that have their own custom templates which is mentioned below in the Templating section of this document.
+*Blog*+ This Channel is (obviously) the site's blog. It is a pretty generic blog setup. * 1 Category Group is used * The Channel has it's own Template Group with a few templates * The default Status Group is used * 6 Custom Fields are used ** blog_meta_description (Text Input, not required, searchable, no formatting) ** blog_introduction (Textarea, required, searchable, XHTML formatting) ** blog_thumbnail (Text Input, not required, not searchable, no formatting, uses file chooser) ** blog_tags (Text Input, not required, searchable, no formatting, basic implementation of "tags" for our entries) ** blog_gallery (Matrix with File Chooser & Text Input, Maximum of 10 rows) ** blog_full_content (Wygwam, uses standard toolbar & Default Upload Directory for uploads) The Blog has the following pages on the site: * Blog landing page (/blog) * Archive page (/blog/archive) * Authors Page (/blog/authors) * Categories list (/blog/categories) * Single Entries (/blog/blog-title-here) Each template used in the pages above are discussed in more detail in the Tempalting section of this document.
Groups Our site is maintained by a couple of developers. The content is reviewed by a site Editor. The blog articles are written by a combination of the site Editor and guest authors. Thus our _utilized_ Member Groups are: * *Super Admins* - obviously the developers on the site with full access to everything * *Editors* - The site editor. Publish/Edit access to all Channels, can edit categories, access to Structure, the works. They also have access to Member management so they can add/edit the "guest authors" at will. *NO* access to Templates, other Modules, Any admin preferences etc. * *Authors* - Guest authors. Publish/Edit access to _their_ entries in the Blog channel. Cannot edit categories or access Structure. When they create blog entries the Status is set to Closed so the Editor can review before posting to the site. Authors do still have access to the Control Panel for the management of their entries. Other default Member Groups are not widely used. There is no site registration so "Allow New Member Registration" is set to "No" and all "guest authors" are registered manually by the Editor.
Template Group / Template Structure * embeds ** embeds/_header ** embeds/_footer ** embeds/_main_menu * site ** site/index (home page only, hardcoded Pages entry) ** site/_pages (default Structure Pages template) * blog ** blog/index (blog landing page) ** blog/categories (list of categories & entry count, links to pages like /blog/category/tech) ** blog/authors (list of our authors, nothing special) ** blog/_entry (single blog entry page, the default blog entry template in Structure) ** blog/archive (archive by month for our blog entries) * specific_pages ** specific_pages/_contact (Structure: template with contact form used only for our Contact Page) ** specific_pages/_map (Structure: template with interactive map used only for our Map page) ** specific_pages/_social (Structure: template with multiple social RSS feed integrations only used for our Social page)
Global Variables There are only a few Global Variables in play across this site. They are all set in our config bootstrap. The most common use is running a template conditional to see what environment we are in. For example, we only load our statistics tracking script if we're in our production environment so that might look like this: <code> {if env == 'prod'} // Javascript inserted here {/if} </code> h3. Inline Commenting We heavily comment our templates in-line when there are unclear steps or chunks of code. For specifics on what each template does open each template. Each template starts with a commented bit of info including the purpose of the template, the cache settings, PHP mode (if applicable) and potential embedded variables.
about HTML tidiness. ‣ With EE in play you will have either ‣ clean EE templates or ‣ clean end-result markup ‣ Your EE templates should be easy to read TEMPLATES & GROUPS 38
friend. ‣ They don’t get parsed to the HTML ‣ Using a syntax-highlighting IDE will help them standout ‣ Use them in big blocks or single lines TEMPLATES & GROUPS 40
always have a class including our country_seg global variable It may also include an id or additional classes which would be embedded variables passed by other templates --} <body{if embed:body_id} id="{embed:body_id}"{/if} class="{country_seg}{if embed:body_class} {embed:body_class}{/if}"> {!-- We add in Google Analytics if we're in our Production environment. See config.php --} {if app_env == 'prod'} <script type="text/javascript"> // GA Javascript junk here </script> {/if} {!-- page-specific embeds based on the Structure page_slug --} {if '{exp:structure:page_slug}' == 'videos'} {embed='embeds/_videos'} {/if} {if '{exp:structure:page_slug}' == 'user-guides'} {embed='embeds/_guides'} {/if} {!-- End page-specific embeds based on the Structure page_slug --} TEMPLATES & GROUPS 44
a conditional to check if we're on a parent category or not. Parent categories (there are currently 3) have their own template. Use the 3rd Party Low Seg2Cat Extension to get the category parent ID from the URL segment. In our site there are 2 levels of categories. If a Category has a parent ID of “0” then it is a parent. Otherwise it is a child. --} {if '{segment_3_category_parent_id}' != '0'} {embed="products/child_category"} {if:else} {embed="products/parent_category"} {/if} 45
* EE Template Notes * account/index is the default template for the account home page * The region must have "has_cart" set to "y" in path.php to view this page */ --} {if has_cart != 'y'}{redirect=''}{/if} {embed='embeds/_masthead' body_id="account" body_class="page" page_title="My Account" } {embed='embeds/_header'} <div id="main"> {if logged_in} {embed="account/user"} {if:else} {embed="account/login"} {/if} </div> {embed='embeds/_footer'} 46
* EE Template Notes * embeds/_masthead is a hidden template only used with embeds * Potential embedded variables passed to it including page_title, body_id & body_class */ --} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>{if embed:page_title != ''}{embed:page_title} | {/if}{site_name} {country_name}</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> {embed:add_meta} <link rel="shortcut icon" href="/images/favicon.jpg" /> {!-- Cache Buster 3rd Party Add-on for ExpressionEngine Checks the save time meta data of a flat file and adds a "cache buster" string to make sure that the user downloads the most recent version This plugin is used on all CSS and JS references on the site @see http://devot-ee.com/add-ons/cache-buster/ --} <link rel="stylesheet" href="{exp:cache_buster file='/css/style.css'}" type="text/css" media="screen" charset="utf-8"/> <link rel="stylesheet" href="{exp:cache_buster file='/css/print.css'}" type="text/css" media="print" charset="utf-8" /> 47
h2. 3rd Party Add-ons We are only using a handfull of Add-ons that alter the site significantly. They are: * Structure * NSM Transplant * ER Developer Toolbar h3. Structure "Structure":http://buildwithstructure.com is used to better manage the majority of our URLs (foregoing the template_group/template approach EE does out of the box). We use Structure to also help the client see (and easily re-arrange) their site's Pages hierarchy. Structure has some handy tags in use across the site. The HTML Title is built with Structure. The sub navigation is all built with Structure. The primary navigation, however, is not. (That is hard-coded in the embeds/_main_menu template.) Structure allows for the customizing of templates on a per-entry basis. We use that on a few entries and that is the sole reason for the entire "specific_pages" Template Group.
h3. NSM Transplant We are using "NSM Transplant":http://expressionengine-addons.com/nsm-transplant to cut down on queries across our templates. It allows us to occasionally save pieces of data from within a Channel Entries loop and use it outside that loop later in the template. You can find more on that here: http://expressionengine-addons.com/ nsm-transplant. This only affects our templates, not the back-end. h3. ER Developer Toolbar "ER Developer Toolbar":http://erikreagan.com/projects/er-developer-toolbar/ is just a toolbar shown on the front-end of the website. It is a module with links to pages on the back-end making it easier to develop the site and manage content for the Editor. There are Module settings that allow toolbar configurations for each member group. The toolbar only displays for Super Admins and Editors. More info here: http://erikreagan.com/ projects/er-developer-toolbar/