Building custom CMS applications on WordPress

Preview:

DESCRIPTION

 

Citation preview

Building Custom CMS Applications on WordPressmitcho (Michael 芳貴 Erlewine)

CMS

There’s no such thing as a CMS success story.The  Trouble  With  Back-­‐EndsErin  Griffith,  Adweek,  August  9,  2011adweek.com/print/133917

it’s all about the C and M

CMS

FALSE

1. Content2. Management1. C2. M

Today:

1. Content

The essence of man is discontent, divine discontent...

the essence of web is content, divine content.

José Ortega y Gasset

1. Content

what is the content?is the metadata?

where is the data?

Text?That’s so 2000s.

Global ShakespearesMIT Shakespeare Projectglobalshakespeares.org

Hundreds of productions with video

Document Revisions by Ben Balterwordpress.org/extend/plugins/wp-document-revisions

pressfs by Joseph Scottjosephscott.org/pressfs-a-wordpress-filesystem

Build featuresnot post types

In development: Shakespeare scripts

Scripts are XML files, not content text in WordPressNo editor needed

Registering scripts

register_post_type('script', array( 'label' => 'Scripts', 'public' => true, 'hierarchical' => false, 'supports' => array('title', 'xmldoc', 'comments'), 'taxonomies' => array('post_tag')));

XML Documents with XSLT stylesheetswordpress.org/extend/plugins/xml-documents

instead of ‘editor’

Post Type Features

post type features

post title, editor, author, thumbnail, excerpt, trackbacks, custom-fields, comments, revisions, post-formats

page title, editor, author, thumbnail, page-attributes, custom-fields, comments, revisions

attachment comments

default title, editor

// if ( 'script' == $post_type )

Check for features

if ( post_type_supports( $post_type, 'xmldoc' ) )if ( 'script' == $post_type )

Get meta.Define your metadata.

metadata in WordPress{taxonomy

organizationalsearch, sortingcan be hierarchicallike tags, categories

post metanon-organizationalspecific to the content itemlike custom fields

Taxonomy Queriesquery_posts( array( 'post_type' => 'production', 'tax_query' => array( array( 'taxonomy' => 'play', 'terms' => array( 'hamlet' ), 'field' => 'slug' ), array( 'taxonomy' => 'language', 'terms' => array( 'japanese', 'mandarin' ), 'field' => 'slug' ) ));

WordPressis not an island

Edgerton Digital CollectionsMIT Museum and MIT Edgerton Centerhttp://edgerton-digital-collections.org

12000 photos, 8000 notebook pages

All assets from the MIT Museum databasein MIMSY, a commercial collection management app

Edgerton

• Custom post type for museum assets• Specify ID, get image and metadata

from museum DB• Site-specific metadata (comments,

tags) in WordPress

Remote data

• Hit external APIs with wp_remote_request() and friends

• Cache results in Post Meta, Object Cache, Transients, as appropriate

Search integration

• Simple trick: put searchable text versions of custom content in post_content

• Roll out a separate search

1. Content

what is the content?is the metadata?

where is the data?

2. Management

who contributes/edits/curates/maintains it?

2. Management

how will it be managed?

Who’s who?

Work for the weekend

add_filter( 'user_has_cap', 'workweek', 10, 3 );

function workweek( $allcaps, $caps, $args ) { $user = get_userdata( $args[1] ); $weekend = ( date( 'N' ) > 5 ); if ( $args[0] == 'publish_posts' && $user->user_email = 'jane@automattic.com' && $weekend ) $allcaps['publish_posts'] = false; return $allcaps;}

Keep It Simple,Smartypants.

Shakespeare: rich metadata on each production

Production metadata consolidated into one meta boxUse add_meta_box(), intercept data with ‘save_post’ filter.

KISS

add_filter( 'default_hidden_meta_boxes', function( $hidden ) { $hidden[] = 'myboxid'; $hidden[] = 'anotherboxid'; //... return $hidden; });

The right tool (?)for the job

Shakespeare: some video datasubmitted by researchers in Excel format

Solution: a simple (custom) CSV file importer

$id = wp_insert_post( array( 'post_title' => 'WP Hamlet', 'post_status' => 'publish', 'post_type' => 'production', 'tax_input' => array( 'play' => 'hamlet', 'director' => 'matt-mullenweg', 'language' => 'php' )) );

Add post meta separately.

Insert the post

WARNING:

• This is a balancing act• Moving to WordPress can be a great

way to build new sustainable habits• Not all traditions are constructive

what is the content?is the metadata?

where is the data?who contributes/edits/

curates/maintains it?how will it be managed?

kick-ass CMS applications

Discontent is the first step in the progress of a man or nation...content is the first concern in the progress of a website.

Oscar Wilde

thank you.Q?

mitcho (Michael 芳貴 Erlewine)mitcho.com; @themitcho; slideshare.net/mitcho