Skip to content

Instantly share code, notes, and snippets.

View Sym2.3 custom data source.php
<?php
require_once(TOOLKIT . '/class.datasource.php');
Class datasourcetour_l_current_presentation_images extends SectionDatasource{
public $dsParamROOTELEMENT = 'tour-l-current-presentation-images';
public $dsParamORDER = 'asc';
public $dsParamPAGINATERESULTS = 'yes';
public $dsParamLIMIT = '1';
View master.xml
<data>
<params>
<workspace>http://192.168.1.4/symphony/workspace</workspace>
</params>
<images>
<section id="4" handle="images">Images</section>
<entry id="42">
<image-title handle="preview">Preview</image-title>
<image size="50 KB" path="/images/projektai" type="image/jpeg">
<filename>beute-beispielfoto-gruppe.jpg</filename>
@DavidOliver
DavidOliver / symphony-cms-caching-extensions.md
Created Nov 3, 2012 — forked from anonymous/gist:4008089
A guide to caching extensions (Symphony CMS) by Nick Dunn
View symphony-cms-caching-extensions.md

There are many types of caching that will improve website performance. Here are just five:

MySQL query caching

Every read query that Symphony executes is cached by MySQL. It is important to understand that this is not the result of the query, but the SQL statement itself. MySQL retains a pool of these statements so that they are quicker to execute in the future. This is pretty standard, and you can use it in your own applications too by using SELECT SQL_CACHE for your read queries.

Object caching

Once the database has been queried, the results are used to build objects (pages, data sources, sections, field, entries etc.). These objects are alive only for the lifespan of each page, and are destroyed at the end of each request. Systems such as Wordpress allow these objects to be cached and persisted between each page request (using APC, Memcache, flat files or MySQL), thereby shared between all users. Symphony doesn't do this, but it really should.

Fragment caching

If you have one piece of a p

@DavidOliver
DavidOliver / event.save_order.php
Created Jul 10, 2012
Symphony CMS event to save a customer order
View event.save_order.php
<?php
require_once(TOOLKIT . '/class.event.php');
Class eventsave_order extends Event{
const ROOTELEMENT = 'save-order';
public $eParamFILTERS = array(
'etm-new-order-notification'
@DavidOliver
DavidOliver / SymCMS - Getting data notes.mkd
Last active Mar 29, 2019
Notes on getting data from within Symphony CMS
View SymCMS - Getting data notes.mkd

Written based on hacking away at a custom event which aimed to take its data solely from entry data and $_SESSION values, and not posted values (which I understand may have been open to DOM hacking and required "ugly" frontend hidden fields).

Things I think I've learned

Use Xpath in PHP when possible

I was traversing the XMLElement object generated by SymQL (or Entry object generated by EntryManager) with the object's methods and foreach to get values, which seems to require a lot of effort and code:

<?php
View master.xml
<?xml version="1.0" encoding="utf-8" ?>
<data>
<corsi-per-tutti>
<section id="7" handle="corsi-per-tutti">Corsi per tutti</section>
<entry id="69">
<titolo handle="corsi-intensivi-di-lingua">Corsi intensivi di lingua</titolo>
</entry>
<entry id="67">
<titolo handle="prezzi">Prezzi</titolo>
</entry>
@DavidOliver
DavidOliver / data.parts.php
Created Feb 10, 2012
Calculating parts prices - Symphony CMS
View data.parts.php
<?php
public function grab(&$param_pool=NULL){
$result = new XMLElement($this->dsParamROOTELEMENT);
try{
include(TOOLKIT . '/data-sources/datasource.section.php');
}
catch(FrontendPageNotFoundException $e){
// Work around. This ensures the 404 page is displayed and
// is not picked up by the default catch() statement below
@DavidOliver
DavidOliver / data.parts.php
Created Feb 8, 2012
Custom data source for Symphony CMS
View data.parts.php
<?php
public function grab(&$param_pool=NULL){
$result = new XMLElement('parts');
// Get default settings from database
$defaults_query = "SELECT * FROM sym_sv_parts_defaults LIMIT 1";
$defaults_result = Symphony::Database()->fetch($defaults_query);
// Set default profit margin
@DavidOliver
DavidOliver / sym2.3-backend-markup.htm
Created Oct 6, 2011
Symphony CMS 2.3 backend markup idea
View sym2.3-backend-markup.htm
<!DOCTYPE html>
<html>
<head>
<title>Symphony – Sections</title>
</head>
<body>
<form action="/symphony/blueprints/sections" method="post">
<header id="header">