Slide 1

Slide 1 text

F FOCUS B { } DOCUMENTING EXPRESSIONENGINE Contributing to the sanity of developers everywhere

Slide 2

Slide 2 text

@ERIKREAGAN. ENGINE SUMMIT . OCT A BIT OF CONTEXT Documentation for managing content on your site is important and worthy of an equally stimulating presentation. 2

Slide 3

Slide 3 text

@ERIKREAGAN. ENGINE SUMMIT . OCT A BIT OF CONTEXT But that’s not the kind of documentation we’re talking about today. 3

Slide 4

Slide 4 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Documentation for you. The developer. And other developers. A BIT OF CONTEXT 4

Slide 5

Slide 5 text

@ERIKREAGAN. ENGINE SUMMIT . OCT WHY DOCUMENT? 5

Slide 6

Slide 6 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Consider these scenarios: ‣ Coming back to an old project after 1 year ‣ New team member needs the rundown ‣ You drop development for musical theater WHY DOCUMENT? 6

Slide 7

Slide 7 text

@ERIKREAGAN. ENGINE SUMMIT . OCT We all provide a service whether it is to a client or an organization employing us. Our practices should serve their best interest. WHY DOCUMENT? 7

Slide 8

Slide 8 text

@ERIKREAGAN. ENGINE SUMMIT . OCT It’s responsible. Good for you. Good for your client or organization. WHY DOCUMENT? 8

Slide 9

Slide 9 text

@ERIKREAGAN. ENGINE SUMMIT . OCT HOW DO I DOCUMENT? 9

Slide 10

Slide 10 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ‣ Whatever is quick and efficient for you ‣ Don’t spend too much time on this ‣ Use a format all developers can use HOW DO I DOCUMENT? 10

Slide 11

Slide 11 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Easy to read. Easy to update. HOW DO I DOCUMENT? 11

Slide 12

Slide 12 text

@ERIKREAGAN. ENGINE SUMMIT . OCT HOW DO I DOCUMENT? ‣ Plaint Text ‣ Textile ‣ Markdown ‣ Whatever your IDE syntax highlighter displays legibly Textile in TextMate 12

Slide 13

Slide 13 text

@ERIKREAGAN. ENGINE SUMMIT . OCT HOW DO I DOCUMENT? Textile in TextMate in Preview Mode ( ⌃⌥⌘ P ) Textile in TextMate 13

Slide 14

Slide 14 text

@ERIKREAGAN. ENGINE SUMMIT . OCT HOW DO I DOCUMENT? Go to Symbol in TextMate Textile document ( ⇧ ⌘ T ) 14

Slide 15

Slide 15 text

@ERIKREAGAN. ENGINE SUMMIT . OCT WHAT TO DOCUMENT 15

Slide 16

Slide 16 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Anything that may change from one site to another. WHAT TO DOCUMENT 16

Slide 17

Slide 17 text

@ERIKREAGAN. ENGINE SUMMIT . OCT In ExpressionEngine, that means we have our work cut out for us. WHAT TO DOCUMENT 17

Slide 18

Slide 18 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ‣ Server Environments ‣ Channels & Related Groups ‣ Member Groups ‣ Templates & Groups ‣ 3rd Party Add-ons WHAT TO DOCUMENT 18

Slide 19

Slide 19 text

@ERIKREAGAN. ENGINE SUMMIT . OCT SERVER ENVIRONMENTS 19

Slide 20

Slide 20 text

@ERIKREAGAN. ENGINE SUMMIT . OCT If your site exists in multiple environments, you need to document the differences & how you handle them. SERVER ENVIRONMENTS 20

Slide 21

Slide 21 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ‣ Environment software versions ‣ PHP/Apache library/module requirements ‣ config.php ‣ 3rd Party Add-on paths ‣ e.g. ED ImageResizer or FieldFrame SERVER ENVIRONMENTS 21

Slide 22

Slide 22 text

@ERIKREAGAN. ENGINE SUMMIT . OCT SERVER ENVIRONMENTS 22 h2. Server 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

Slide 23

Slide 23 text

@ERIKREAGAN. ENGINE SUMMIT . OCT SERVER ENVIRONMENTS 23 (continued from 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/

Slide 24

Slide 24 text

@ERIKREAGAN. ENGINE SUMMIT . OCT CHANNELS & RELATED GROUPS 24

Slide 25

Slide 25 text

@ERIKREAGAN. ENGINE SUMMIT . OCT CHANNELS & RELATED GROUPS More than one way to skin a cat Note: I do not condone the skinning of cats. 25

Slide 26

Slide 26 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ‣ How a Channel relates 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

Slide 27

Slide 27 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ‣ Custom Field Groups relating to Channels ‣ 3rd Party Fieldtypes & existing usage ‣ Any custom written FIeldtypes? ‣ Publish Layout Overview CHANNELS & RELATED GROUPS 27

Slide 28

Slide 28 text

@ERIKREAGAN. ENGINE SUMMIT . OCT CHANNELS & RELATED GROUPS 28 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.

Slide 29

Slide 29 text

@ERIKREAGAN. ENGINE SUMMIT . OCT CHANNELS & RELATED GROUPS 29 +*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.

Slide 30

Slide 30 text

@ERIKREAGAN. ENGINE SUMMIT . OCT MEMBER GROUPS 30

Slide 31

Slide 31 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ‣ Group permissions & uses ‣ Who has Control Panel access? ‣ Any SAEF’s in action ‣ Any member spam prevention in place MEMBER GROUPS 31

Slide 32

Slide 32 text

@ERIKREAGAN. ENGINE SUMMIT . OCT MEMBER GROUPS 32 h2. Member 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.

Slide 33

Slide 33 text

@ERIKREAGAN. ENGINE SUMMIT . OCT TEMPLATES & GROUPS 33

Slide 34

Slide 34 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Two places to document: ‣ In our master documentation file and ‣ In-line comments in our templates TEMPLATES & GROUPS 34

Slide 35

Slide 35 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Master documentation file ‣ Brief overview of templates groups ‣ Use of Snippets ‣ Use of Global Variables ‣ Any access restriction in play? TEMPLATES & GROUPS 35

Slide 36

Slide 36 text

@ERIKREAGAN. ENGINE SUMMIT . OCT TEMPLATES & GROUPS 36 h3. 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)

Slide 37

Slide 37 text

@ERIKREAGAN. ENGINE SUMMIT . OCT TEMPLATES & GROUPS 37 h3. 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: {if env == 'prod'} // Javascript inserted here {/if} 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.

Slide 38

Slide 38 text

@ERIKREAGAN. ENGINE SUMMIT . OCT In-line template commenting ‣ Forget 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

Slide 39

Slide 39 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Browsers don’t care how “pretty” it is. Let go of your inner-geek in this instance. Accept “messy” markup. TEMPLATES & GROUPS 39

Slide 40

Slide 40 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ‣ EE comments are your 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

Slide 41

Slide 41 text

@ERIKREAGAN. ENGINE SUMMIT . OCT TEMPLATES & GROUPS ‣ Start every template with a comment header ‣ When is the template used? ‣ What Channels use this template? ‣ If PHP is enabled be sure to specify that 41

Slide 42

Slide 42 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ‣ Document even the tiniest template ‣ Don’t assume you’ll remember how it works ‣ Don’t assume someone else will understand it TEMPLATES & GROUPS 42

Slide 43

Slide 43 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Sample Snippets TEMPLATES & GROUPS 43

Slide 44

Slide 44 text

@ERIKREAGAN. ENGINE SUMMIT . OCT {!-- Our body tag will 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 --} {!-- We add in Google Analytics if we're in our Production environment. See config.php --} {if app_env == 'prod'} // GA Javascript junk here {/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

Slide 45

Slide 45 text

@ERIKREAGAN. ENGINE SUMMIT . OCT TEMPLATES & GROUPS {!-- Run 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

Slide 46

Slide 46 text

@ERIKREAGAN. ENGINE SUMMIT . OCT TEMPLATES & GROUPS {!-- /** * 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'}
{if logged_in} {embed="account/user"} {if:else} {embed="account/login"} {/if}
{embed='embeds/_footer'} 46

Slide 47

Slide 47 text

@ERIKREAGAN. ENGINE SUMMIT . OCT TEMPLATES & GROUPS {!-- /** * 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 */ --} {if embed:page_title != ''}{embed:page_title} | {/if}{site_name} {country_name} {embed:add_meta} {!-- 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/ --} 47

Slide 48

Slide 48 text

@ERIKREAGAN. ENGINE SUMMIT . OCT RD PARTY ADD ONS 48

Slide 49

Slide 49 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Document any 3rd Party Add-ons that alter front-end output. Document any 3rd Party Add-ons that alter back-end workflow. RD PARTY ADD ONS 49

Slide 50

Slide 50 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Front-end examples: ‣ Structure ‣ Low Variables ‣ NavEE ‣ Super Search ‣ NSM Transplant RD PARTY ADD ONS 50

Slide 51

Slide 51 text

@ERIKREAGAN. ENGINE SUMMIT . OCT Back-end examples: ‣ Structure ‣ Low Variables ‣ NavEE ‣ Solspace Calendar ‣ NSM Publish Plus RD PARTY ADD ONS 51

Slide 52

Slide 52 text

@ERIKREAGAN. ENGINE SUMMIT . OCT RD PARTY ADD ONS 52 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.

Slide 53

Slide 53 text

@ERIKREAGAN. ENGINE SUMMIT . OCT RD PARTY ADD ONS 53 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/

Slide 54

Slide 54 text

@ERIKREAGAN. ENGINE SUMMIT . OCT OTHER CONSIDERATIONS 54

Slide 55

Slide 55 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ‣ Multi-site manager use ‣ Custom add-ons ‣ Additional PHP libraries for CI/EE ‣ Any tie-ins to external sites or services ‣ Any core hacks OTHER CONSIDERATIONS 55

Slide 56

Slide 56 text

@ERIKREAGAN. ENGINE SUMMIT . OCT ANY QUESTIONS? 56

Slide 57

Slide 57 text

@ERIKREAGAN. ENGINE SUMMIT . OCT THANKS! Erik Reagan Owner & Lead Developer Focus Lab, LLC focuslabllc.com erikreagan.com @erikreagan / @focuslabllc slides available at slideshare.net/erikreagan F FOCUS B { } 57