53
Building Custom CMS Applications on W ordPress mitcho (Michael 貴 Erlewine)

CMS content

Embed Size (px)

DESCRIPTION

cccccccccccc

Citation preview

Page 1: CMS content

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

Page 3: CMS content

CMS

Page 4: CMS content

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

Page 5: CMS content

it’s all about the C and M

CMS

Page 6: CMS content

FALSE

Page 8: CMS content

1. Content2. Management1. C2. M

Today:

Page 9: CMS content

1. Content

Page 10: CMS content

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

the essence of web is content, divine content.

José Ortega y Gasset

Page 11: CMS content

1. Content

what is the content?is the metadata?

where is the data?

Page 12: CMS content

Text?That’s so 2000s.

Page 13: CMS content

Global ShakespearesMIT Shakespeare Projectglobalshakespeares.org

Page 14: CMS content

Hundreds of productions with video

Page 15: CMS content

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

Page 16: CMS content

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

Page 17: CMS content

Build featuresnot post types

Page 18: CMS content

In development: Shakespeare scripts

Page 19: CMS content

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

Page 20: CMS content
Page 21: CMS content
Page 22: CMS content

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’

Page 23: CMS content

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

Page 24: CMS content

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

Check for features

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

Page 25: CMS content

Get meta.Define your metadata.

Page 26: CMS content

metadata in WordPress{taxonomy

organizationalsearch, sortingcan be hierarchicallike tags, categories

post metanon-organizationalspecific to the content itemlike custom fields

Page 28: CMS content

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' ) ));

Page 29: CMS content

WordPressis not an island

Page 30: CMS content

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

Page 31: CMS content

12000 photos, 8000 notebook pages

Page 32: CMS content

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

Page 33: CMS content

Edgerton

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

from museum DB• Site-specific metadata (comments,

tags) in WordPress

Page 34: CMS content

Remote data

• Hit external APIs with wp_remote_request() and friends

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

Page 35: CMS content

Search integration

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

• Roll out a separate search

Page 36: CMS content

1. Content

what is the content?is the metadata?

where is the data?

Page 37: CMS content

2. Management

Page 38: CMS content

who contributes/edits/curates/maintains it?

2. Management

how will it be managed?

Page 39: CMS content

Who’s who?

Page 40: CMS content

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 = '[email protected]' && $weekend ) $allcaps['publish_posts'] = false; return $allcaps;}

Page 41: CMS content

Keep It Simple,Smartypants.

Page 42: CMS content

Shakespeare: rich metadata on each production

Page 43: CMS content

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

Page 44: CMS content

KISS

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

Page 45: CMS content

The right tool (?)for the job

Page 46: CMS content

Shakespeare: some video datasubmitted by researchers in Excel format

Page 47: CMS content

Solution: a simple (custom) CSV file importer

Page 48: CMS content

$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

Page 49: CMS content

WARNING:

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

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

Page 50: CMS content

what is the content?is the metadata?

where is the data?who contributes/edits/

curates/maintains it?how will it be managed?

Page 51: CMS content

kick-ass CMS applications

Page 52: CMS content

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

Page 53: CMS content

thank you.Q?

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