SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
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
What is your current
platform of choice?
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
For who is MODX
• Web Professionals
• Designers
• Front-end developers
• Using MODX as a tool
• Est 4-5.000.000 sites
Community
• Free addons: 622
• Official Forum: forums.modx.com 50.571
• +- 1M views of modx.com per month
• Twitter: #MODX
• Slack: modx.org 289
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]]
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
$obj = $modx->getObject(‘modChunk’, 5);
$c = array(‘name’ => ‘head’);
$obj = $modx->getObject(‘modChunk’, $c)
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 {
}
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;

}
Custom Resources
• Extend the base modResource object
• Custom processing logic
• Custom UI
Custom User Objects
• Extend the base modUser object
• Custom authentication logic
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/15171 => talk feedback
Enjoy your Creative Freedom
Thanks

Mais conteúdo relacionado

Mais procurados

How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP frameworkDinh Pham
 
Tools and Tips for Moodle Developers - #mootus16
 Tools and Tips for Moodle Developers - #mootus16 Tools and Tips for Moodle Developers - #mootus16
Tools and Tips for Moodle Developers - #mootus16Dan Poltawski
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingRobert Carr
 
Your first d8 module
Your first d8 moduleYour first d8 module
Your first d8 moduletedbow
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module developmentDamjan Cvetan
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8Allie Jones
 
Drupal 7 Theme System
Drupal 7 Theme SystemDrupal 7 Theme System
Drupal 7 Theme SystemPeter Arato
 
Brisbane Drupal meetup - 2016 Mar - Build module in Drupal 8
Brisbane Drupal meetup - 2016 Mar - Build module in Drupal 8Brisbane Drupal meetup - 2016 Mar - Build module in Drupal 8
Brisbane Drupal meetup - 2016 Mar - Build module in Drupal 8Vladimir Roudakov
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Andreas Jung
 
Thymeleaf Introduction
Thymeleaf IntroductionThymeleaf Introduction
Thymeleaf IntroductionAnthony Chen
 
Getting started with drupal 8 code
Getting started with drupal 8 codeGetting started with drupal 8 code
Getting started with drupal 8 codeForum One
 
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 GrailsPhilip Stehlik
 
20110606 e z_flow_gig_v1
20110606 e z_flow_gig_v120110606 e z_flow_gig_v1
20110606 e z_flow_gig_v1Gilles Guirand
 

Mais procurados (20)

How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP framework
 
Content Modeling Behavior
Content Modeling BehaviorContent Modeling Behavior
Content Modeling Behavior
 
Ppt php
Ppt phpPpt php
Ppt php
 
Php converted pdf
Php converted pdfPhp converted pdf
Php converted pdf
 
Tools and Tips for Moodle Developers - #mootus16
 Tools and Tips for Moodle Developers - #mootus16 Tools and Tips for Moodle Developers - #mootus16
Tools and Tips for Moodle Developers - #mootus16
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) Theming
 
Your first d8 module
Your first d8 moduleYour first d8 module
Your first d8 module
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8
 
Drupal 7 Theme System
Drupal 7 Theme SystemDrupal 7 Theme System
Drupal 7 Theme System
 
Brisbane Drupal meetup - 2016 Mar - Build module in Drupal 8
Brisbane Drupal meetup - 2016 Mar - Build module in Drupal 8Brisbane Drupal meetup - 2016 Mar - Build module in Drupal 8
Brisbane Drupal meetup - 2016 Mar - Build module in Drupal 8
 
A look at Drupal 7 Theming
A look at Drupal 7 ThemingA look at Drupal 7 Theming
A look at Drupal 7 Theming
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011
 
Thymeleaf Introduction
Thymeleaf IntroductionThymeleaf Introduction
Thymeleaf Introduction
 
Lightweight web frameworks
Lightweight web frameworksLightweight web frameworks
Lightweight web frameworks
 
Getting started with drupal 8 code
Getting started with drupal 8 codeGetting started with drupal 8 code
Getting started with drupal 8 code
 
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
 
20110606 e z_flow_gig_v1
20110606 e z_flow_gig_v120110606 e z_flow_gig_v1
20110606 e z_flow_gig_v1
 
Plone 5 theming
Plone 5 themingPlone 5 theming
Plone 5 theming
 
A nodejs application
A nodejs applicationA nodejs application
A nodejs application
 

Semelhante a Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)

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 EngineYared Ayalew
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To DrupalLauren Roth
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGentkevinvw
 
Gajendra sharma Drupal Module development
Gajendra sharma Drupal Module developmentGajendra sharma Drupal Module development
Gajendra sharma Drupal Module developmentGajendra Sharma
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
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 StepsLuís Carneiro
 
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_a4openerpwiki
 
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 PowerShellwalk2talk srl
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical MementoOdoo
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildwebLeo Zhou
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Lucas Jellema
 

Semelhante a Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort) (20)

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
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
 
Tornadoweb
TornadowebTornadoweb
Tornadoweb
 
Gajendra sharma Drupal Module development
Gajendra sharma Drupal Module developmentGajendra sharma Drupal Module development
Gajendra sharma Drupal Module development
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
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
 
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
 
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
 
Php reports sumit
Php reports sumitPhp reports sumit
Php reports sumit
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical Memento
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb
 
Ipc mysql php
Ipc mysql php Ipc mysql php
Ipc mysql php
 
SolrCloud on Hadoop
SolrCloud on HadoopSolrCloud on Hadoop
SolrCloud on Hadoop
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 
Php intro
Php introPhp intro
Php intro
 
Php intro
Php introPhp intro
Php intro
 
Php intro
Php introPhp intro
Php intro
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
 

Mais de Mark Hamstra

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.0Mark Hamstra
 
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, 2019Mark Hamstra
 
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)Mark Hamstra
 
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 Mark Hamstra
 
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)Mark Hamstra
 
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)Mark Hamstra
 
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)Mark Hamstra
 
MODX Weekend 2014 - Welcome Slides
MODX Weekend 2014 - Welcome SlidesMODX Weekend 2014 - Welcome Slides
MODX Weekend 2014 - Welcome SlidesMark Hamstra
 
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:30Mark Hamstra
 

Mais 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
 

Último

『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationMarko4394
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 

Último (17)

『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 

Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)

  • 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
  • 4. What is your current platform of choice?
  • 5. 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
  • 7. For who is MODX • Web Professionals • Designers • Front-end developers • Using MODX as a tool • Est 4-5.000.000 sites
  • 8. Community • Free addons: 622 • Official Forum: forums.modx.com 50.571 • +- 1M views of modx.com per month • Twitter: #MODX • Slack: modx.org 289
  • 9. 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
  • 11. Elements as Building Blocks Templates TemplateVariables Chunks Snippets Plugins
  • 12. Templates • Usually HTML • Contains MODX tags • One template per page
  • 13. 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]]
  • 14. Chunks • Usually HTML • Reusable piece of code • [[$name-of-chunk]] Template Chunk “head”
  • 15. Snippets • PHP! • Comparable to a function • Accepts properties • [[name-of-snippet]] or 
 [[!name-of-snippet]] Snippet “helloWorld” Template
  • 17. 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]]
  • 18. Plugins • PHP! • Event-based, so no tags • Can read and often influence behaviour
  • 19. 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
  • 20. Example: getResources • Lists resources matching conditions • Uses a Chunk as template • Use Cases: • Article listings • Dynamic (sub)menus • RSS feed generation Template Chunk “blogListItem”
  • 21. Time for a Manager Tour! http://localhost/tmp/phpfrl/manager/
  • 23. 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
  • 24. xPDO • Object Relational Bridge / ORM • Open Source (modxcms/xpdo) • Extension to PHP’s PDO • Support for MySQL, sqlsrv (and more)
  • 25. Fetching a Single Object $obj = $modx->getObject(‘modChunk’, 5); $c = array(‘name’ => ‘head’); $obj = $modx->getObject(‘modChunk’, $c)
  • 26. Easy Query Builder $c = $modx->newQuery(‘modResource’); $c->where([ ‘parent’ => 0, ‘AND:pagetitle:LIKE => ‘%About%’ ]); $matches = $modx->getCollection(‘modResource’, $c); foreach ($matches as $modResource) { . . . }
  • 27. 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’); } 👍 ⚠
  • 28. 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
  • 29. xPDO Package Schema - Head <?xml version="1.0" encoding="UTF-8"?> <model package="phpfrl" baseClass="xPDOSimpleObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
  • 30. 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>
  • 31. 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" />
  • 32. 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>
  • 33. 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>
  • 34. xPDO Generated Model <?php
 class frlMeetup extends xPDOSimpleObject { }
  • 35. 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;
 }
  • 36.
  • 37. Custom Resources • Extend the base modResource object • Custom processing logic • Custom UI
  • 38. Custom User Objects • Extend the base modUser object • Custom authentication logic
  • 39. 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/15171 => talk feedback Enjoy your Creative Freedom