Flexible site structure with cake php
Upcoming SlideShare
Loading in...5
×
 

Flexible site structure with cake php

on

  • 6,026 views

Brief introduction on Implementing a flexible site structure with CakePHP

Brief introduction on Implementing a flexible site structure with CakePHP

Statistics

Views

Total Views
6,026
Views on SlideShare
6,026
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Flexible site structure with cake php Flexible site structure with cake php Presentation Transcript

  • Flexible site structure with CakePHP Andy Gale www.andy-gale.com
  • T3A gadget,technology andlifestyle magazine
  • T3Internationallylicensed...
  • T3Pioneering interactive iPad magazine
  • T3 Future Publishing• A popular title on Zino - an online publishing platform www.zinio.com• Also a popular UK website destination for gadget fans www.t3.com
  • T3 Future Publishing• Flagship brand for Future Publishing• T3 Awards being an important part of the UK calendar• Many competitors - online, blogs such as Engadget and Gizmodo• Quick-to-publish vital on gadget websites
  • T3 - Just use Drupal or Wordpress!• Many Future websites now in Drupal or Wordpress www.pcgamer.com www.netmagazine.com• Pressflow (a distribution of Drupal) is an excellent platform for publishing websites pressflow.org• Drupal and Pressflow with Varnish scales www.varnish-cache.org
  • T3 - Just use Drupal or Wordpress?• No need to build another CMS?• But the site editors had unique requirements for their workflow
  • Editable custom content boxes Popular list features need to be fast and easy to createEasy to update trending and ticker
  • Various different types of galleries including super galleries!
  • Flexible site structure• Obviously, articles, galleries, other lists of content are stored in database• We also stored the site structure in the database using the Tree behaviour.
  • Editable custom content boxes
  • ElementsModel:CREATE TABLE elements (! id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,! name VARCHAR(255) DEFAULT ,! PRIMARY KEY (id));Name field, just the filename of aCakePHP element<div><h3>Latest</h3><ul> <li><a href="/news/iphone5red">iPhone 5 actually Red</a></li> <li><a href="/news/iphone5blue">iPhone 5 to Blue</a></li></ul>[children]
  • SiteObject Elementid: 1 id: 1name: Latest smartphone news name: content_boxes/list.ctptype: ContentBoxelement_id: 1content_id: 50 SiteObject id: 50 name: Latest smartphone news list type: List SiteObject Article id: 51 id: 1 type: List name: Black Samsung parent_id: 50 Galaxy S3 coming soon article_id: 1 SiteObject Article id: 52 id: 2 type: List name: Motorola RAZAR Ice parent_id: 50 Cream Sandwich update out article_id: 2 now SiteObject Article id: 53 id: 3 type: List name: Supposed Apple parent_id: 50 iPhone 5 motherboard hints article_id: 3 at features
  • Hero article content boxSiteObjectid: 1name: Samsung Galaxy Note 2: Hands On Elementtype: ContentBox id: 2element_id: 2 name: content_boxes/hero.ctparticle_id: 4 Article id: 4 name: Black Samsung Galaxy S3 coming soon
  • Tree Behaviour <body> id: 1 left: 1, right: 10 <header> <main> id: 2 id: 5 parent: 1 parent: 1 left: 2, right: 7 left: 8, right: 13<h1> & logo <nav> <article> <aside>id: 3 id: 4 id: 6 id: 7parent: 2 parent: 2 parent: 5 parent: 5left: 3, right: 4 left: 5, right: 6 left: 9, right: 10 left: 11, right: 12 book.cakephp.org/1.3/en/view/1339/Tree
  • So what about the structure?All page elements were grouped togetheras different types of “site object”CREATE TABLE site_objects (! id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,! parent_id INTEGER(10) UNSIGNED DEFAULT NULL,! lft INTEGER(10) UNSIGNED DEFAULT NULL,! rght INTEGER(10) UNSIGNED DEFAULT NULL,! name VARCHAR(255) DEFAULT ,!! page_id INTEGER(10) UNSIGNED DEFAULT NULL,! article_id INTEGER(10) UNSIGNED DEFAULT NULL,! element_id INTEGER(10) UNSIGNED DEFAULT NULL,! content_id INTEGER(10) UNSIGNED DEFAULT NULL,! PRIMARY KEY (id));PageCREATE TABLE pages (! id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,! name VARCHAR(255) DEFAULT ,!! title VARCHAR(255) DEFAULT ,!! meta_description TEXT DEFAULT! meta_keywords TEXT DEFAULT NULL,! name VARCHAR(255) DEFAULT ,!! url VARCHAR(255) DEFAULT ,!! PRIMARY KEY (id));
  • URLs• The structure of each “Page” or URL was defined in a tree• /news takes you to the page structure for news articles• /news/new-iphone5-released takes you to the page structure associated with the new articles that has the slug “new-iphone5-released” allowing different layouts for articles from trades shows
  • Content?• element_id field contains a reference to the element that should be used to display this content• content_id field in SiteObject refers to another SiteObject which contains information about where to find the content• That content could be a list of articles, images, a carousel... anything that the site supports
  • Content?• Backend process updates lists periodically• Key lists such as the homepage lists of articles are updated whenever articles change• Allows easy updating of caching. See: andy-gale.com/positive-cache-clearing-with-cakephp.html
  • Caching!!!!!!• Caching vital when implementing a site using this methodology• Structure and content both SiteObjects can be cached in the same way• Caching need to be updated fast to ensure new articles were published as soon as possible
  • Caching CMS Cache update sent as a topic via STOMP protocol ActiveMQ Multiple clients can subscribe to a topic so all web servers that are listening can update their cache immediately and serve new contentWeb server Web server Web server
  • CSS, elements and flexible Structure• Consistent CSS style guide for each component vital for implementing a flexible site structure• Elements should work wherever they are placed• Twitter Bootstrap is a great example twitter.github.com/bootstrap/
  • Flexible site structure with CakePHP• Code to be released on my GitHub page shortly: github.com/salgo/• Avoiding Surprises with Chef and Vagrant Attend if you’ve ever had problems with configuration or anything else when putting sites live
  • Flexible site structure with CakePHP• Questions?• @andygale on Twitter• andy-gale.com on the Web