SlideShare a Scribd company logo
Flexible site structure
    with CakePHP
       Andy Gale


                   www.andy-gale.com
T3
A gadget,
technology and
lifestyle magazine
T3
Internationally
licensed...
T3
Pioneering 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 create




Easy 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
Elements
Model:
CREATE TABLE elements (
! id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
! name VARCHAR(255) DEFAULT '',
! PRIMARY KEY (id)
);




Name field, just the filename of a
CakePHP 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                               Element
id: 1                                    id: 1
name: Latest smartphone news             name: content_boxes/list.ctp
type: ContentBox
element_id: 1
content_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 box




SiteObject
id: 1
name: Samsung Galaxy Note 2: Hands On            Element
type: ContentBox                                 id: 2
element_id: 2                                    name: content_boxes/hero.ctp
article_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: 7
parent: 2             parent: 2              parent: 5            parent: 5
left: 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 together
as 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)
);

Page
CREATE 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 content




Web 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

More Related Content

PDF
13- Learn CSS Fundamentals / Specificity
PPT
Even faster web sites presentation 3
PDF
Alfresco tech talk live public api episode 64
PDF
10- Learn CSS Fundamentals / Pseudo-elements
PDF
9- Learn CSS Fundamentals / Pseudo-classes
PDF
Intro to WordPress theme development
PDF
PDF
14- Learn CSS Fundamentals / Inheritance
13- Learn CSS Fundamentals / Specificity
Even faster web sites presentation 3
Alfresco tech talk live public api episode 64
10- Learn CSS Fundamentals / Pseudo-elements
9- Learn CSS Fundamentals / Pseudo-classes
Intro to WordPress theme development
14- Learn CSS Fundamentals / Inheritance

What's hot (20)

PDF
Even faster web sites
PDF
Top SEO Factors (2014/2015)
PDF
1428393873 mhkx3 ln
PDF
Ryan Fishberg and Joan Lafferty - ItemsRenderers
PDF
Plug and Play Tools for the Recruiting Empiricist
PPTX
Introduction to HTML5 & CSS3
KEY
Html5的应用与推行
PDF
Getting the most out of Radiant
PDF
Arizona WP - Building a WordPress Theme
PDF
Develop your first mobile App for iOS and Android
PPT
IBM Connection - customize it, #dd13
PDF
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
PPTX
Integrating Search Driven Content in SharePoint 2013/2016/O365
PDF
SharePoint 2013 Search Driven Sites - SPSHOU
PDF
NewBCamp09: Turning your design into a WordPress Theme
PPTX
Integrating citations from RefWorks without Write-N-Cite
PDF
Kohana 3.2 documentation
PDF
Selenium for-ops
PDF
Building Mobile Applications with Ionic
PPTX
Learning Wordpress - the internal guide
Even faster web sites
Top SEO Factors (2014/2015)
1428393873 mhkx3 ln
Ryan Fishberg and Joan Lafferty - ItemsRenderers
Plug and Play Tools for the Recruiting Empiricist
Introduction to HTML5 & CSS3
Html5的应用与推行
Getting the most out of Radiant
Arizona WP - Building a WordPress Theme
Develop your first mobile App for iOS and Android
IBM Connection - customize it, #dd13
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Integrating Search Driven Content in SharePoint 2013/2016/O365
SharePoint 2013 Search Driven Sites - SPSHOU
NewBCamp09: Turning your design into a WordPress Theme
Integrating citations from RefWorks without Write-N-Cite
Kohana 3.2 documentation
Selenium for-ops
Building Mobile Applications with Ionic
Learning Wordpress - the internal guide
Ad

Similar to Flexible site structure with cake php (20)

KEY
The Devil and HTML5
PDF
PDF
Tom Critchlow - Data Feed SEO & Advanced Site Architecture
PDF
12 core technologies you should learn, love, and hate to be a 'real' technocrat
PDF
Html5&css3
PDF
Creating an Effective Mobile API
PDF
Implementing a Symfony Based CMS in a Publishing Company
PPTX
Semantic Collabration Compass
PDF
HTML5 소개 및 배우기- HTML5 Open Conference
PDF
Beginner & Intermediate Guide to HTML5/CSS3 In Drupal
PDF
Web Developing In Search
PDF
Bentobox exercise
PDF
Miha Lesjak Mobilizing The Web with Web Runtime
PDF
Movable Type Seminar 2011
PPTX
The Semantic Web #2 - XML
PPTX
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
PPTX
HTML5 introduction
PDF
Cassandra for Rails
PDF
HTML5 kickstart - Brooklyn Beta workshop 21.10.2010
The Devil and HTML5
Tom Critchlow - Data Feed SEO & Advanced Site Architecture
12 core technologies you should learn, love, and hate to be a 'real' technocrat
Html5&css3
Creating an Effective Mobile API
Implementing a Symfony Based CMS in a Publishing Company
Semantic Collabration Compass
HTML5 소개 및 배우기- HTML5 Open Conference
Beginner & Intermediate Guide to HTML5/CSS3 In Drupal
Web Developing In Search
Bentobox exercise
Miha Lesjak Mobilizing The Web with Web Runtime
Movable Type Seminar 2011
The Semantic Web #2 - XML
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
HTML5 introduction
Cassandra for Rails
HTML5 kickstart - Brooklyn Beta workshop 21.10.2010
Ad

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Spectroscopy.pptx food analysis technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
1. Introduction to Computer Programming.pptx
PDF
August Patch Tuesday
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Getting Started with Data Integration: FME Form 101
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Approach and Philosophy of On baking technology
PPTX
Programs and apps: productivity, graphics, security and other tools
Encapsulation_ Review paper, used for researhc scholars
Per capita expenditure prediction using model stacking based on satellite ima...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
MIND Revenue Release Quarter 2 2025 Press Release
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Spectroscopy.pptx food analysis technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
1. Introduction to Computer Programming.pptx
August Patch Tuesday
SOPHOS-XG Firewall Administrator PPT.pptx
cloud_computing_Infrastucture_as_cloud_p
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Getting Started with Data Integration: FME Form 101
Heart disease approach using modified random forest and particle swarm optimi...
Unlocking AI with Model Context Protocol (MCP)
A comparative study of natural language inference in Swahili using monolingua...
Approach and Philosophy of On baking technology
Programs and apps: productivity, graphics, security and other tools

Flexible site structure with cake php

  • 1. Flexible site structure with CakePHP Andy Gale www.andy-gale.com
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. T3 - Just use Drupal or Wordpress? • No need to build another CMS? • But the site editors had unique requirements for their workflow
  • 9. Editable custom content boxes Popular list features need to be fast and easy to create Easy to update trending and ticker
  • 10. Various different types of galleries including super galleries!
  • 11. 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.
  • 13. Elements Model: CREATE TABLE elements ( ! id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT, ! name VARCHAR(255) DEFAULT '', ! PRIMARY KEY (id) ); Name field, just the filename of a CakePHP 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]
  • 14. SiteObject Element id: 1 id: 1 name: Latest smartphone news name: content_boxes/list.ctp type: ContentBox element_id: 1 content_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
  • 15. Hero article content box SiteObject id: 1 name: Samsung Galaxy Note 2: Hands On Element type: ContentBox id: 2 element_id: 2 name: content_boxes/hero.ctp article_id: 4 Article id: 4 name: Black Samsung Galaxy S3 coming soon
  • 16. 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: 7 parent: 2 parent: 2 parent: 5 parent: 5 left: 3, right: 4 left: 5, right: 6 left: 9, right: 10 left: 11, right: 12 book.cakephp.org/1.3/en/view/1339/Tree
  • 17. So what about the structure? All page elements were grouped together as 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) ); Page CREATE 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) );
  • 18. 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
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. 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 content Web server Web server Web server
  • 23. 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/
  • 24. 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
  • 25. Flexible site structure with CakePHP • Questions? • @andygale on Twitter • andy-gale.com on the Web

Editor's Notes