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

Documenting ExpressionEngine

Embed Size (px)

DESCRIPTION

Slides from Documenting ExpressionEngine from the EngineSummit 2. Discuss the need and approaches to building developer-focused documentation for EE sites.

Citation preview

Page 1: Documenting ExpressionEngine

FFOCUS !B{ }

DOCUMENTING!EXPRESSIONENGINEContributing to the sanity of developers everywhere

Page 2: Documenting ExpressionEngine

@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

Page 3: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

A!BIT!OF!CONTEXT"""

But that’s not the kind of documentation we’re talking about today.

3

Page 4: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

Documentation for you.

The developer.

And other developers.

A!BIT!OF!CONTEXT"""

4

Page 5: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

WHY!DOCUMENT?

5

Page 6: Documenting ExpressionEngine

@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

Page 7: Documenting ExpressionEngine

@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

Page 8: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

It’s responsible.

Good for you.

Good for your client or organization.

WHY!DOCUMENT?

8

Page 9: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

HOW!DO!I!DOCUMENT?

9

Page 10: Documenting ExpressionEngine

@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

Page 11: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

Easy to read.

Easy to update.

HOW!DO!I!DOCUMENT?

11

Page 12: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

HOW!DO!I!DOCUMENT?

‣ Plaint Text

‣ Textile

‣ Markdown

‣ Whatever your IDE syntax highlighter displays legibly

Textile in TextMate

12

Page 13: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

HOW!DO!I!DOCUMENT?

Textile in TextMate in Preview Mode ( ⌃⌥⌘ P )Textile in TextMate

13

Page 14: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

HOW!DO!I!DOCUMENT?

Go to Symbol in TextMate Textile document ( ⇧ ⌘ T )

14

Page 15: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

WHAT!TO!DOCUMENT

15

Page 16: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

Anything that may change from one site to another.

WHAT!TO!DOCUMENT

16

Page 17: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

In ExpressionEngine, that means we have our work cut out for us.

WHAT!TO!DOCUMENT

17

Page 18: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

‣ Server Environments

‣ Channels & Related Groups

‣ Member Groups

‣ Templates & Groups

‣ 3rd Party Add-ons

WHAT!TO!DOCUMENT

18

Page 19: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

SERVER!ENVIRONMENTS

19

Page 20: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

If your site exists in multiple environments, you need to document the differences & how you handle them.

SERVER!ENVIRONMENTS

20

Page 21: Documenting ExpressionEngine

@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

Page 22: Documenting ExpressionEngine

@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

Page 23: Documenting ExpressionEngine

@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/

Page 24: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

CHANNELS!&!RELATED!GROUPS

24

Page 25: Documenting ExpressionEngine

@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

Page 26: Documenting ExpressionEngine

@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

Page 27: Documenting ExpressionEngine

@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

Page 28: Documenting ExpressionEngine

@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.

Page 29: Documenting ExpressionEngine

@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.

Page 30: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

MEMBER!GROUPS

30

Page 31: Documenting ExpressionEngine

@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

Page 32: Documenting ExpressionEngine

@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.

Page 33: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

TEMPLATES!&!GROUPS

33

Page 34: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

Two places to document:

‣ In our master documentation file and

‣ In-line comments in our templates

TEMPLATES!&!GROUPS

34

Page 35: Documenting ExpressionEngine

@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

Page 36: Documenting ExpressionEngine

@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)

Page 37: Documenting ExpressionEngine

@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:

<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.

Page 38: Documenting ExpressionEngine

@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

Page 39: Documenting ExpressionEngine

@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

Page 40: Documenting ExpressionEngine

@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

Page 41: Documenting ExpressionEngine

@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

Page 42: Documenting ExpressionEngine

@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

Page 43: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

Sample Snippets

TEMPLATES!&!GROUPS

43

Page 44: Documenting ExpressionEngine

@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--}<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

Page 45: Documenting ExpressionEngine

@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

Page 46: Documenting ExpressionEngine

@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'}

<div id="main">

{if logged_in}{embed="account/user"}{if:else}{embed="account/login"}{/if} </div>

{embed='embeds/_footer'}

46

Page 47: Documenting ExpressionEngine

@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 */--}<!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

Page 48: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

"RD!PARTY!ADD#ONS

48

Page 49: Documenting ExpressionEngine

@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

Page 50: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

Front-end examples:

‣ Structure

‣ Low Variables

‣ NavEE

‣ Super Search

‣ NSM Transplant

"RD!PARTY!ADD#ONS

50

Page 51: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

Back-end examples:

‣ Structure

‣ Low Variables

‣ NavEE

‣ Solspace Calendar

‣ NSM Publish Plus

"RD!PARTY!ADD#ONS

51

Page 52: Documenting ExpressionEngine

@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.

Page 53: Documenting ExpressionEngine

@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/

Page 54: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

OTHER!CONSIDERATIONS

54

Page 55: Documenting ExpressionEngine

@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

Page 56: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

ANY!QUESTIONS?

56

Page 57: Documenting ExpressionEngine

@ERIKREAGAN. ENGINE!SUMMIT ". OCT "#$#

THANKS!

Erik ReaganOwner & Lead DeveloperFocus Lab, LLC

focuslabllc.comerikreagan.com@erikreagan / @focuslabllc

slides available at slideshare.net/erikreagan

FFOCUS !B{ }

57