Pixel & Tonic

Blog & Tonic

Making P&T: Docs

Posted by Brandon Kelly on Mar 4, 2010

This is the third installment in a series about the design and development behind what is now Pixel & Tonic. Yesterday we looked at how the site is structured, and how we’re handling URLs. Today I’m going to focus on how I’m managing my product documentation.


When I decided to migrate my FieldFrame documentation from the GitHub wiki to brandon-kelly.com, I was spoiled by a variety of approaches to choose from. I could have simply created a “FieldFrame Docs” weblog, and created a contents tree with your standard {exp:weblog:entries} tag, or done something a bit more interesting using Structure.

But as I’m always looking to bend my own products in strange new ways, what I came up with was quite absurd.

I started by creating that FieldFrame Docs weblog and giving each page its own entry. For the contents tree, I made a new FF Matrix field within my EE Add-ons field group, and gave it two cells: Page (a Playa select related to the Docs weblog), and Alternate Heading (a text field). I wanted to be able to organize my pages into groups, so a row with an Alt Heading set would appear as a heading, and the others would be linked titles. I also created a new FF Matrix celltype, “FFM Hierarchy”, and used that to establish a hierarchy within the tree.

It might look decent, but in practice it’s been a pain in the ass to maintain. Every time I wanted to add a new page, I’d first create the new page’s entry, then go to FieldFrame’s entry, add a new row to the Docs matrix and relate it to the page. If that page was to be placed anywhere but at the end, the hierarchy would tend to get screwed up, and require readjustment. Oh, and when I gave Playa its own Docs section, I had to relate the Playa cell to its weblog as well as FieldFrame Docs, so if I wasn’t careful I could accidentally relate FieldFrame to a Playa Docs page, and vise-versa.

But the worst part was the templates. There was the site/_docs template (routed from site/index and site/_apps), which displayed the current page’s contents:

{exp:weblog:entries dynamic="off" weblog="docs_{segment_1}"
       url_title="{segment_3}{if segment_3 == ''}docs_{segment_1}{/if}"
       limit="1" ... }

{embed="site/_docs_tree" url_title="{url_title}" title="{title}"}
   <div class="col first wide body">
       {exp:textile}{docs_body}{/exp:textile}
   </div>
{/exp:weblog:entries}

And the subsequently-embedded site/_docs_tree was responsible for building the actual contents tree, as well as embedding the site header and footer:

{exp:weblog:entries dynamic="off" weblog="ee" url_title="{segment_1}"
       limit="1" ... }

{embed="site/_header" ... }

<ul class="subnav"> ... </ul>

<h1>{embed:title}</h1>

<div class="col last callout">
   <h3>{title} Documentation</h3>

   <ul>
       {docs_tree}
           <li>
               {if page}
                   {page}<a{if url_title == "{embed:url_title}"} class="active"{/if} href="/{segment_1}/{segment_2}{if url_title != weblog_short_name}/{url_title}{/if}">
                       {title}
                   </a>{/page}
               {if:else}
                   <h4>{heading}</h4>
               {/if}
               {if subpages}
                   <ul>
                       {subpages}
                   </ul>
               {/if}
           </li>
       {/docs_tree}
   </ul>
</div>

{/exp:weblog:entries}

It was a mess.

The Docs Module

Thankfully I decided to use EE2 on pixelandtonic.com, where such an abomination isn’t yet possible, while I wait for… myself… to port FF Matrix over. So this time around, I took the cleanest possible approach: I wrote a new module!

Thanks to EE2’s new module tab API, each of my EE Add-on entries have their own “Docs” tab on the publish page, where I can manage all documentation for that entry, including the hierarchy:

Docs module tab

And since my module’s tag pair doesn’t conflict with {exp:weblog:entries}, I can now fit the entire Docs page in a single primary template, ee/docs:

{exp:channel:entries channel="ee" url_title="{segment_3}" ...}
{exp:docs:page entry_id="{entry_id}" url_title="{segment_4}"}
{embed="site/-header" title="{title} - Docs - {docs_page_title}" ...}
{embed="ee/-header" title="{title}" ...}

<div class="content">
    <div class="grid23 clearafter">
        <div class="left">
            {if segment_4}<h1>{docs_page_title}</h1>{/if}
            {docs_page_contents}
        </div>
        <nav class="right">
            {exp:docs:tree entry_id="{entry_id}" base_url="{site_url}{url_title}/docs" selected="{docs_page_url_title}"}
        </nav>
    </div>
</div>

{embed="site/-footer"}
{/exp:docs:page}
{/exp:channel:entries}

In its current state, the module is pretty simple – pages are stored in their own table, and are only given the four fields shown above (Parent, Title, URL Title, and Contents). Page order is defined by drag-n-dropping the pages within the contents tree on the right. The module has two tags, one for outputting the entire tree in an unordered list (not currently customizable), and one for outputting a single page’s contents.

It’s a good starting point, but there are areas for improvement. Once I’m done porting Playa and Matrix to EE2, I’d like to go back and add HTML archive exporting (for on-the-fly downloadable docs) and maybe even release branching.

Release?

Whether or not I release Docs publicly is up in the air. I’ll do it if there’s sufficient demand; otherwise it’ll remain private. So if you think you could use this, sound off in the comments! Include your use case for extra P&T Points (worth about 1/2 a Schrute Buck in today’s economy).


And that’s it for today; thanks for tuning in! This series will continue tomorrow with a look into how I’m managing releases and processing payments, so make sure you’re following @pixelandtonic or subscribed to our RSS feed to be notified about that.

Comments

Lodewijk Schutte
Lodewijk Schutte

Mmm, that Docs module looks delicious. Definitely going to be needing that if/when I migrate to EE2 myself. I’m currently just using an embed with lots of conditionals for docs that span multiple pages. There’s something rustic about using the old-skool way, but it feels kind of dirty sometimes… So bring it!

Olivier
{url_as_author}

This is very good… I could certainly use it right now.

I’m Building a “Dealer Portal” for a client where they can list their products and include documentation as a downloadable pdf.
Downside are 1) the documentation isn’t readable online, 2) confusion/mistake happen when pdfs are being updated and people forget to update the website blah blah blah…

With something like this, the documentation could live online and online only. You mention “HTML archive exporting” how about pdf export (hint hint)...

I have made many ee site for product base companies and many involved documentation of some sort, so in brief, for me, this would rock.

Oh… and thank you for sharing(again)

Brandon Kelly
Brandon Kelly

I hadn’t even considered PDF exporting, but honestly I like the sound of that way more than HTML archiving. Much cleaner!

Richard Lomas
{url_as_author}

Yes please on Docs.

I even promise not to start posting endless issues and support requests on GetSatisfaction!

grin

Olivier
{url_as_author}

This could sure ad value when selling sites to client…

Aaron Bushnell
Aaron Bushnell

I’m going to give a huge thumbs up to the Docs add-on.  I’ve found myself struggling on good hierarchy methods with EE.  EE2’s custom tabbing can really take advantage of this.

Brent
{url_as_author}

Sounds like another standard add-on for client sites to me…

Brian Hildreth
Brian Hildreth

That does sound tasty. Most of my EE builds are for small to medium sized businesses. Almost everyone has some documents they want to share and almost all of them are simple text that should be HTML. Giving them an easy way to create the docs and give the site users a clean way to save as a .pfd if they so choose sounds sweet.

The place where I know I can use this on every EE build, is using this add-on to create an online user guide for my clients for their site. Right now, I design them a user guide in InDesign and give them a printed copy and a .pdf.

Aaron Bushnell
Aaron Bushnell

Totally agree with Brian.  I find it difficult to get an easy way for clients to create and reorder a hierarchy on their own.  Sometimes I like sharing that control, sometimes not so much.  This is great for that.

Ian Beck
Ian Beck

Although I wouldn’t be able to sell a docs module to many clients, it would be invaluable for my own site. When I redesigned the site, I actually based the documentation table of contents setup pretty heavily on brandon-kelly.com because I really liked how you had things separated out into subheadings that weren’t pages themselves.

My use-case is pretty similar to your own: I have a number of software projects, some of which need dedicated documentation sections.

Right now, the table of contents are just hard-coded into templates, and the next/previous links at the bottom are hard-coded in the content of the pages.  Both of these are a pain to maintain, but quickest to setup.  I’d love to migrate to something that allowed me to add pages, edit the hierarchy, and so forth in the admin area.

Fabian Socarras
Fabian Socarras

I’d buy five licenses right now if it were available.

Andrew Gunstone
Andrew Gunstone

I am definitely a +1 for the release. I don’t have anything particular in mind for it, but to be honest, I CAN see that I would find a use!

Jim Wyse
Jim Wyse

We write documentation and tutorials for our editors using the weblog method. What would really be kewl is a module that admins can post help and tutorials for editors and clients that are accessed from a tab in the CP. Editable by assigned groups, and readable by the others.

I could still use something like this on the front end as well. Could it parlay into something like a knowledge base for site visitors?

The interesting bit is there could be so many usefull variations on this theme!

Jim

John Hoysa
{url_as_author}

This sounds great for clients sites. PDF export sounds like a great feature as well.

Brian Mason
Brian Mason

Docs doc docs yes!  Looks fantastic. Things like this will definitely get me to move onto the 2.0 train sooner rather than later!

Anthony DeCrescenzo
{url_as_author}

Howzit feel to not even KNOW you have you finger so on the pulse of this community, BK?

I just yesterday received notification that I won a bid for the development of a residential co-op’s website. One of the items they were seriously interested in was the ability to put all policies and policy changes—everything—online and viewable by residents. The various policy docs have a very definite hierarchy, even down to some being required/obligatory and some being optional.

This looks like it might be a very interesting option (if released), ESPECIALLY coupled with the “downloadable PDF” option discussed above.

Yes, yes, yes indeedy. You are one busy beaver, BK. (Stay, I’ll fix you another…just keep at it…)

Anthony DeCrescenzo
{url_as_author}

(And why can’t I set my OWN mug as my avatar instead of the amber goodness pictured.)

Anthony DeCrescenzo
{url_as_author}

Spammy strangeness above aside, have you come any closer to being the Decider on this item, Brandon? Still interested, for the reasons outlined in my first comment.

Brandon Kelly
Brandon Kelly

I’ve changed the workflow a bit since launching the site, and I’m still not 100% happy with it. Until I am, I can’t even consider releasing it, sorry.

Ferienhaus
Ferienhaus

Looks fantastic. Sooner or later these will move to include in any case and on the 2.0 train.

Reiseführer
Reiseführer

This sounds great for clients sites. PDF export sounds like a great feature as well.
.

Comments off.