SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
Unleashing Creative
Freedom with
Who am I?
Mark Hamstra
Founder & CEA at modmore
Freelance MODX Developer
my doggies
Turbo
Bommel
Agenda
• What is MODX, for whom, available
features, how to build a MODX site
• Tour of the MODX Manager (back-end)
• The Architecture of MODX, xPDO ORM,
extending and overriding, the future
MOD-what?
• Open Source
• Written in PHP (of course)
• Primarily used with MySQL, other drivers available
• Already 10 years old young
• Content Management System Framework Platform
https://twitpic.com/3pvrmw
All the features of a CMS
rich text editor versioning user groups
multisite templates multilingual extensions
markdown media browser hierarchical
page tree commercial support automatic
menu builder blogging permissions seo
friendly urls server-side caching
Installs without Assumptions
Elements as Building Blocks
Templates
TemplateVariables
Chunks
Snippets
Plugins
Templates
• Usually HTML
• Contains MODX tags
• One template per page
Template Variables
• Custom field for resources
• Commonly “TV”
• Tied to templates
• Text, image, select, checkbox,
date, radio, richtext, tag and
custom types available
• [[*name-of-tv]]
Chunks
• Usually HTML
• Reusable piece of code
• [[$name-of-chunk]]
Template
Chunk “head”
Snippets
• PHP!
• Comparable to a function
• Accepts properties
• [[name-of-snippet]] or 

[[!name-of-snippet]]
Snippet “helloWorld”
Template
Snippets
But wait, there’s more!
• [[name-of-snippet]]
• [[!name-of-snippet]]
• = uncached!
• [[++name-of-setting]]

[[!++name-of-setting]]
• [[$name-of-chunk]]

[[!$name-of-chunk]]
• [[*name-of-field]]

[[!*name-of-field]]
But wait, there’s even more!
• [[helloWorld?

&property=`value`

]]
• [[$head?

&extraCss=`<link rel=.. href=..>`

]]
Plugins
• PHP!
• Event-based, so no tags
• Can read and often
influence behaviour
No need to reinvent

the wheel
• Packages (aka extras, add-
ons, extensions, third party
components…) provide
common functionality
• Install via Package Installer
inside the manager
Example: getResources
• Lists resources matching
conditions
• Uses a Chunk as template
• Use Cases:
• Article listings
• Dynamic (sub)menus
• RSS feed generation
Template
Chunk “blogListItem”
Time for a Manager Tour!
http://localhost/tmp/phpfrl/manager/
MODX Architecture
Secure by Design
• Automatic $_GET, $_POST, $_REQUEST
sanitisation in the request handler
• xPDO ORM prevents SQL Injections
• 28 CVE entries, 8 since 2014
• WordPress: 906, already ~85 in 2015
• Drupal: 915, already ~120 in 2015
2015-07, cve.mitre.org
xPDO
• Object Relational Bridge / ORM
• Open Source (modxcms/xpdo)
• Extension to PHP’s PDO
• Support for MySQL, sqlsrv (and more)
Fetching a Single Object
$c = 5;
$obj = $modx->getObject(‘modChunk’, $c);
$c2 = array(‘name’ => ‘head’);
$obj = $modx->getObject(‘modChunk’, $c2)
Easy Query Builder
$c = $modx->newQuery(‘modResource’);
$c->where([
‘parent’ => 0,
‘AND:pagetitle:LIKE => ‘%About%’
]);
$matches = $modx->getCollection(‘modResource’, $c);
foreach ($matches as $modResource) { . . . }
Automatic Filtering
$search = $_POST[‘search’];
$c = $modx->newQuery(‘modResource’);
$c->where([
‘introtext:LIKE’ => “%{$search}%”,
]);
$modx->setPlaceholder(‘search’, sanitise($search));
function sanitise($value) { return htmlentities($value,
ENT_QUOTES, ‘UTF-8’); }
👍
⚠
Custom Models with xPDO
1. Create an xPDO Package Schema (XML)
2. Use build script to write schema into the actual
model files/classes
3. Register it before use ($modx->addPackage)
4. Use any xPDO method (getObject,
getCollection) on your custom model
xPDO Package Schema - Head
<?xml version="1.0" encoding="UTF-8"?>
<model package="phpfrl"
baseClass="xPDOSimpleObject"
platform="mysql"
defaultEngine="MyISAM"
version="1.1">
xPDO Package Schema - Object
<?xml version="1.0" encoding="UTF-8"?>
<model package=“phpfrl” …
<object class="frlMeetup" table=“meetups”>
.. fields ..
</object>
<object class="frlSpeaker" table=“speakers”> … </object>
</model>
xPDO Package Schema - Fields
<?xml version="1.0" encoding="UTF-8"?>
<model package=“phpfrl” …
<object class="frlMeetup" table=“meetups">
<field 

key="name" 

dbtype="varchar" 

precision="100" 

phptype="string" 

null="false" 

default=“PHP FRL Meetup" />
xPDO Package Schema - Indices
<?xml version="1.0" encoding="UTF-8"?>
<model package=“phpfrl” …
<object class="frlMeetup" table=“meetups">

<field key="name" dbtype=“varchar" …

<field key=“starts_on" dbtype=“datetime"

<field key="name" dbtype=“varchar" …
<index alias="name" name="name" primary="false"
unique="false" type="BTREE">

<column key="name" length="" collation="A" null="false" />

</index>

</object>
xPDO Package Schema - Relations
<?xml version="1.0" encoding="UTF-8"?>
<model package=“phpfrl” baseClass=“xPDOSimpleObject" …
<object class="frlMeetup" table=“meetups">

<field key="name" dbtype=“varchar” …>
<composite alias=“Speakers” class=“frlSpeaker” local=“id” foreign=“meetup”
cardinality=“many” owner=“local” />

</object>
<object class="frlSpeaker" table=“speakers">

<field key="name" dbtype=“varchar” …>

<field key="meetup" dbtype=“int” …>
<aggregate alias=“Meetup” class=“frlMeetup” local=“meetup” foreign=“id”
cardinality=“one” owner=“foreign” />

</object>
xPDO Generated Model
<?php

class frlMeetup extends xPDOSimpleObject {
}
<?php
class frlMeetup_mysql extends frlMeetup {
}
Interacting with that model
$modx->addPackage(‘phpfrl’, ‘/path/to/model/‘);
$c = $modx->newQuery(‘frlMeetup’);

$c->sortby(‘starts_on’, ‘DESC’);

$meetup = $modx->getObject(‘frlMeetup’, $c);
echo ‘De volgende meetup is ‘ . $meetup->name . ‘ en vind plaats op ‘ . $meetup-
>starts_on . ‘. ’;
$speakers = $meetup->getMany(‘Speakers’); // or just $meetup->Speakers

foreach ($speakers as $spegfytaker) {

echo $speaker->name . ‘ zal vertellen over ‘ . $speaker->subject;

}
The Future of MODX
• MODX 3 & MODX Next
• Backwards incompatible release (semver)
• Cleaning up legacy code no longer relevant
• Full namespace support for xPDO models
• Composer/packagist support
• Proper Dependency Injection in the core
• Improved, faster routing with Slim
Interesting links:
• MODX.com => official website
• rtfm.modx.com => official documentation
• github.com/modxcms/revolution => source code
• MODX.today => daily links/articles about MODX
• modmore.com => premium extras for MODX
• https://joind.in/talk/view/15031 => please leave feedback
Enjoy your Creative Freedom

Contenu connexe

Tendances

Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and GrailsPhilip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik
 
Django Framework and Application Structure
Django Framework and Application StructureDjango Framework and Application Structure
Django Framework and Application Structure
SEONGTAEK OH
 

Tendances (20)

Content Modeling Behavior
Content Modeling BehaviorContent Modeling Behavior
Content Modeling Behavior
 
PHP Profiling/performance
PHP Profiling/performancePHP Profiling/performance
PHP Profiling/performance
 
Doing Drupal security right
Doing Drupal security rightDoing Drupal security right
Doing Drupal security right
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) Theming
 
XUL - Mozilla Application Framework
XUL - Mozilla Application FrameworkXUL - Mozilla Application Framework
XUL - Mozilla Application Framework
 
the 5 layers of web accessibility - Open Web Camp II
the 5 layers of web accessibility - Open Web Camp IIthe 5 layers of web accessibility - Open Web Camp II
the 5 layers of web accessibility - Open Web Camp II
 
Two scoops of django 1.6 - Ch7, Ch8
Two scoops of django 1.6  - Ch7, Ch8Two scoops of django 1.6  - Ch7, Ch8
Two scoops of django 1.6 - Ch7, Ch8
 
Progressive Downloads and Rendering
Progressive Downloads and RenderingProgressive Downloads and Rendering
Progressive Downloads and Rendering
 
Ppt php
Ppt phpPpt php
Ppt php
 
Php converted pdf
Php converted pdfPhp converted pdf
Php converted pdf
 
YSlow 2.0
YSlow 2.0YSlow 2.0
YSlow 2.0
 
A look at Drupal 7 Theming
A look at Drupal 7 ThemingA look at Drupal 7 Theming
A look at Drupal 7 Theming
 
Thymeleaf Introduction
Thymeleaf IntroductionThymeleaf Introduction
Thymeleaf Introduction
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 
JavaScript Frameworks for SharePoint add-ins Cambridge
JavaScript Frameworks for SharePoint add-ins CambridgeJavaScript Frameworks for SharePoint add-ins Cambridge
JavaScript Frameworks for SharePoint add-ins Cambridge
 
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and GrailsPhilip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
 
Django Framework and Application Structure
Django Framework and Application StructureDjango Framework and Application Structure
Django Framework and Application Structure
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
Getting started with drupal 8 code
Getting started with drupal 8 codeGetting started with drupal 8 code
Getting started with drupal 8 code
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 

Similaire à Unleashing Creative Freedom with MODX - 2015-08-26 at PHP Zwolle

An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
Gavin Roy
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
kevinvw
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
Lauren Roth
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
Chalermpon Areepong
 
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Lucidworks
 

Similaire à Unleashing Creative Freedom with MODX - 2015-08-26 at PHP Zwolle (20)

CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShellCCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
 
Tornadoweb
TornadowebTornadoweb
Tornadoweb
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Browser Serving Your Web Application Security - Madison PHP 2017
Browser Serving Your Web Application Security - Madison PHP 2017Browser Serving Your Web Application Security - Madison PHP 2017
Browser Serving Your Web Application Security - Madison PHP 2017
 
Browser Serving Your We Application Security - ZendCon 2017
Browser Serving Your We Application Security - ZendCon 2017Browser Serving Your We Application Security - ZendCon 2017
Browser Serving Your We Application Security - ZendCon 2017
 
Browser Serving Your Web Application Security - NorthEast PHP 2017
Browser Serving Your Web Application Security - NorthEast PHP 2017Browser Serving Your Web Application Security - NorthEast PHP 2017
Browser Serving Your Web Application Security - NorthEast PHP 2017
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
Php reports sumit
Php reports sumitPhp reports sumit
Php reports sumit
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
 
PHP com MongoDB
PHP com MongoDBPHP com MongoDB
PHP com MongoDB
 
Ipc mysql php
Ipc mysql php Ipc mysql php
Ipc mysql php
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First Steps
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb
 
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
 

Plus de Mark Hamstra

Plus de Mark Hamstra (9)

The (Long) Road to Commerce 1.0
The (Long) Road to Commerce 1.0The (Long) Road to Commerce 1.0
The (Long) Road to Commerce 1.0
 
Improving the MODX Documentation - March 29, 2019
Improving the MODX Documentation - March 29, 2019Improving the MODX Documentation - March 29, 2019
Improving the MODX Documentation - March 29, 2019
 
Commerce in 30 minutes (November 15, 2018 at MODX Meetup Maastricht)
Commerce in 30 minutes (November 15, 2018 at MODX Meetup Maastricht)Commerce in 30 minutes (November 15, 2018 at MODX Meetup Maastricht)
Commerce in 30 minutes (November 15, 2018 at MODX Meetup Maastricht)
 
MODX Meetup 2018-03-07 - Introduction talk
MODX Meetup 2018-03-07 - Introduction talk MODX Meetup 2018-03-07 - Introduction talk
MODX Meetup 2018-03-07 - Introduction talk
 
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
 
Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
 
Solving the Workflow (or, how MODX.today is being built with git and Gitify)
Solving the Workflow (or, how MODX.today is being built with git and Gitify)Solving the Workflow (or, how MODX.today is being built with git and Gitify)
Solving the Workflow (or, how MODX.today is being built with git and Gitify)
 
MODX Weekend 2014 - Welcome Slides
MODX Weekend 2014 - Welcome SlidesMODX Weekend 2014 - Welcome Slides
MODX Weekend 2014 - Welcome Slides
 
MODXpo 2013 - The Business of Premium - Day 2, 14:30
MODXpo 2013 - The Business of Premium - Day 2, 14:30MODXpo 2013 - The Business of Premium - Day 2, 14:30
MODXpo 2013 - The Business of Premium - Day 2, 14:30
 

Dernier

Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
imonikaupta
 

Dernier (20)

Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...
Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...
Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 

Unleashing Creative Freedom with MODX - 2015-08-26 at PHP Zwolle

  • 2. Who am I? Mark Hamstra Founder & CEA at modmore Freelance MODX Developer my doggies Turbo Bommel
  • 3. Agenda • What is MODX, for whom, available features, how to build a MODX site • Tour of the MODX Manager (back-end) • The Architecture of MODX, xPDO ORM, extending and overriding, the future
  • 4. MOD-what? • Open Source • Written in PHP (of course) • Primarily used with MySQL, other drivers available • Already 10 years old young • Content Management System Framework Platform
  • 6. All the features of a CMS rich text editor versioning user groups multisite templates multilingual extensions markdown media browser hierarchical page tree commercial support automatic menu builder blogging permissions seo friendly urls server-side caching
  • 8. Elements as Building Blocks Templates TemplateVariables Chunks Snippets Plugins
  • 9. Templates • Usually HTML • Contains MODX tags • One template per page
  • 10. Template Variables • Custom field for resources • Commonly “TV” • Tied to templates • Text, image, select, checkbox, date, radio, richtext, tag and custom types available • [[*name-of-tv]]
  • 11. Chunks • Usually HTML • Reusable piece of code • [[$name-of-chunk]] Template Chunk “head”
  • 12. Snippets • PHP! • Comparable to a function • Accepts properties • [[name-of-snippet]] or 
 [[!name-of-snippet]] Snippet “helloWorld” Template
  • 14. But wait, there’s more! • [[name-of-snippet]] • [[!name-of-snippet]] • = uncached! • [[++name-of-setting]]
 [[!++name-of-setting]] • [[$name-of-chunk]]
 [[!$name-of-chunk]] • [[*name-of-field]]
 [[!*name-of-field]]
  • 15. But wait, there’s even more! • [[helloWorld?
 &property=`value`
 ]] • [[$head?
 &extraCss=`<link rel=.. href=..>`
 ]]
  • 16. Plugins • PHP! • Event-based, so no tags • Can read and often influence behaviour
  • 17. No need to reinvent
 the wheel • Packages (aka extras, add- ons, extensions, third party components…) provide common functionality • Install via Package Installer inside the manager
  • 18. Example: getResources • Lists resources matching conditions • Uses a Chunk as template • Use Cases: • Article listings • Dynamic (sub)menus • RSS feed generation Template Chunk “blogListItem”
  • 19. Time for a Manager Tour! http://localhost/tmp/phpfrl/manager/
  • 21. Secure by Design • Automatic $_GET, $_POST, $_REQUEST sanitisation in the request handler • xPDO ORM prevents SQL Injections • 28 CVE entries, 8 since 2014 • WordPress: 906, already ~85 in 2015 • Drupal: 915, already ~120 in 2015 2015-07, cve.mitre.org
  • 22. xPDO • Object Relational Bridge / ORM • Open Source (modxcms/xpdo) • Extension to PHP’s PDO • Support for MySQL, sqlsrv (and more)
  • 23. Fetching a Single Object $c = 5; $obj = $modx->getObject(‘modChunk’, $c); $c2 = array(‘name’ => ‘head’); $obj = $modx->getObject(‘modChunk’, $c2)
  • 24. Easy Query Builder $c = $modx->newQuery(‘modResource’); $c->where([ ‘parent’ => 0, ‘AND:pagetitle:LIKE => ‘%About%’ ]); $matches = $modx->getCollection(‘modResource’, $c); foreach ($matches as $modResource) { . . . }
  • 25. Automatic Filtering $search = $_POST[‘search’]; $c = $modx->newQuery(‘modResource’); $c->where([ ‘introtext:LIKE’ => “%{$search}%”, ]); $modx->setPlaceholder(‘search’, sanitise($search)); function sanitise($value) { return htmlentities($value, ENT_QUOTES, ‘UTF-8’); } 👍 ⚠
  • 26. Custom Models with xPDO 1. Create an xPDO Package Schema (XML) 2. Use build script to write schema into the actual model files/classes 3. Register it before use ($modx->addPackage) 4. Use any xPDO method (getObject, getCollection) on your custom model
  • 27. xPDO Package Schema - Head <?xml version="1.0" encoding="UTF-8"?> <model package="phpfrl" baseClass="xPDOSimpleObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
  • 28. xPDO Package Schema - Object <?xml version="1.0" encoding="UTF-8"?> <model package=“phpfrl” … <object class="frlMeetup" table=“meetups”> .. fields .. </object> <object class="frlSpeaker" table=“speakers”> … </object> </model>
  • 29. xPDO Package Schema - Fields <?xml version="1.0" encoding="UTF-8"?> <model package=“phpfrl” … <object class="frlMeetup" table=“meetups"> <field 
 key="name" 
 dbtype="varchar" 
 precision="100" 
 phptype="string" 
 null="false" 
 default=“PHP FRL Meetup" />
  • 30. xPDO Package Schema - Indices <?xml version="1.0" encoding="UTF-8"?> <model package=“phpfrl” … <object class="frlMeetup" table=“meetups">
 <field key="name" dbtype=“varchar" …
 <field key=“starts_on" dbtype=“datetime"
 <field key="name" dbtype=“varchar" … <index alias="name" name="name" primary="false" unique="false" type="BTREE">
 <column key="name" length="" collation="A" null="false" />
 </index>
 </object>
  • 31. xPDO Package Schema - Relations <?xml version="1.0" encoding="UTF-8"?> <model package=“phpfrl” baseClass=“xPDOSimpleObject" … <object class="frlMeetup" table=“meetups">
 <field key="name" dbtype=“varchar” …> <composite alias=“Speakers” class=“frlSpeaker” local=“id” foreign=“meetup” cardinality=“many” owner=“local” />
 </object> <object class="frlSpeaker" table=“speakers">
 <field key="name" dbtype=“varchar” …>
 <field key="meetup" dbtype=“int” …> <aggregate alias=“Meetup” class=“frlMeetup” local=“meetup” foreign=“id” cardinality=“one” owner=“foreign” />
 </object>
  • 32. xPDO Generated Model <?php
 class frlMeetup extends xPDOSimpleObject { } <?php class frlMeetup_mysql extends frlMeetup { }
  • 33. Interacting with that model $modx->addPackage(‘phpfrl’, ‘/path/to/model/‘); $c = $modx->newQuery(‘frlMeetup’);
 $c->sortby(‘starts_on’, ‘DESC’);
 $meetup = $modx->getObject(‘frlMeetup’, $c); echo ‘De volgende meetup is ‘ . $meetup->name . ‘ en vind plaats op ‘ . $meetup- >starts_on . ‘. ’; $speakers = $meetup->getMany(‘Speakers’); // or just $meetup->Speakers
 foreach ($speakers as $spegfytaker) {
 echo $speaker->name . ‘ zal vertellen over ‘ . $speaker->subject;
 }
  • 34. The Future of MODX • MODX 3 & MODX Next • Backwards incompatible release (semver) • Cleaning up legacy code no longer relevant • Full namespace support for xPDO models • Composer/packagist support • Proper Dependency Injection in the core • Improved, faster routing with Slim
  • 35. Interesting links: • MODX.com => official website • rtfm.modx.com => official documentation • github.com/modxcms/revolution => source code • MODX.today => daily links/articles about MODX • modmore.com => premium extras for MODX • https://joind.in/talk/view/15031 => please leave feedback Enjoy your Creative Freedom