Building custom CMS applications on WordPress

9,719 views

Published on

Published in: Technology

Building custom CMS applications on WordPress

  1. 1. Building CustomCMS Applicationson WordPressmitcho (Michael 貴 Erlewine)
  2. 2. THIS GUY mitcho.comDOWN HERE @themitcho slideshare.net/mitcho
  3. 3. CMS
  4. 4. There’s no suchthing as a CMSsuccess story.The  Trouble  With  Back-­‐EndsErin  Griffith,  Adweek,  August  9,  2011adweek.com/print/133917
  5. 5. CMSit’s all about the C and M
  6. 6. FALSE
  7. 7. CC-BY-NC-SA flickr.com/photos/13382424@N00/5216424459/
  8. 8. Today:1. Content C2. Management M
  9. 9. 1. Content
  10. 10. The essence of man isdiscontent, divine discontent... the essence of web is content, divine content. José Ortega y Gasset
  11. 11. 1. Content what is the content? is the metadata? where is the data?
  12. 12. Text?That’s so 2000s.
  13. 13. Global ShakespearesMIT Shakespeare Project globalshakespeares.org
  14. 14. Hundreds of productions with video
  15. 15. Document Revisions by Ben Balterwordpress.org/extend/plugins/wp-document-revisions
  16. 16. pressfs by Joseph Scottjosephscott.org/pressfs-a-wordpress-filesystem
  17. 17. Build featuresnot post types
  18. 18. In development: Shakespeare scripts
  19. 19. Scripts are XML files, not content text in WordPress No editor needed
  20. 20. Registering scriptsregister_post_type(script, array( label => Scripts, instead of ‘editor’ public => true, hierarchical => false, supports => array(title, xmldoc, comments), taxonomies => array(post_tag))); XML Documents with XSLT stylesheets wordpress.org/extend/plugins/xml-documents
  21. 21. Post Type Features post type features title, editor, author, thumbnail, excerpt, trackbacks, post custom-fields, comments, revisions, post-formats title, editor, author, thumbnail, page-attributes, page custom-fields, comments, revisions attachment comments default title, editor
  22. 22. Check for featuresif if ( script == $post_type// ( script == $post_type ) )if ( post_type_supports( $post_type, xmldoc ) )
  23. 23. Get meta.Define your metadata.
  24. 24. metadata in WordPress { taxonomyorganizationalsearch, sortingcan be hierarchical post meta non-organizational specific to the content itemlike tags, categories like custom fields
  25. 25. CC BY-NC-SA flickr.com/photos/w3p706/2432014896/http://ottopress.com/2011/when- to-not-use-a-custom-taxonomy/
  26. 26. 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 ) ));
  27. 27. WordPressis not an island
  28. 28. Edgerton Digital CollectionsMIT Museum and MIT Edgerton Centerhttp://edgerton-digital-collections.org
  29. 29. 12000 photos, 8000 notebook pages
  30. 30. All assets from the MIT Museum databasein MIMSY, a commercial collection management app
  31. 31. Edgerton• Custom post type for museum assets • Specify ID, get image and metadata from museum DB • Site-specific metadata (comments, tags) in WordPress
  32. 32. Remote data• Hit external APIs with wp_remote_request() and friends• Cache results in Post Meta, Object Cache, Transients, as appropriate
  33. 33. Search integration• Simple trick: put searchable text versions of custom content in post_content• Roll out a separate search
  34. 34. 1. Content what is the content? is the metadata? where is the data?
  35. 35. 2. Management
  36. 36. 2. Management who contributes/edits/ curates/maintains it? how will it be managed?
  37. 37. Who’s who?
  38. 38. Work for the weekendadd_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;}
  39. 39. Keep It Simple,Smartypants.
  40. 40. Shakespeare: rich metadata on each production
  41. 41. Production metadata consolidated into one meta boxUse add_meta_box(), intercept data with ‘save_post’ filter.
  42. 42. KISSadd_filter( default_hidden_meta_boxes, function( $hidden ) { $hidden[] = myboxid; $hidden[] = anotherboxid; //... return $hidden; });
  43. 43. The right tool (?)for the job
  44. 44. Shakespeare: some video datasubmitted by researchers in Excel format
  45. 45. Solution: a simple (custom) CSV file importer
  46. 46. Insert the post$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.
  47. 47. NING:WA R• This is a balancing act • Moving to WordPress can be a great way to build new sustainable habits • Not all traditions are constructive
  48. 48. what is the content? is the metadata?where is the data?who contributes/edits/ curates/maintains it?how will it be managed?
  49. 49. kick-ass CMS applications
  50. 50. 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
  51. 51. thank you. Q?mitcho (Michael 貴 Erlewine)mitcho.com; @themitcho; slideshare.net/mitcho

×