Skip to content

Instantly share code, notes, and snippets.

@DavidOliver
DavidOliver / sym2.3-backend-markup.htm
Created October 6, 2011 07:48
Symphony CMS 2.3 backend markup idea
<!DOCTYPE html>
<html>
<head>
<title>Symphony – Sections</title>
</head>
<body>
<form action="/symphony/blueprints/sections" method="post">
<header id="header">
@DavidOliver
DavidOliver / data.parts.php
Created February 10, 2012 14:33
Calculating parts prices - Symphony CMS
<?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
<?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 / event.save_order.php
Created July 10, 2012 13:58
Symphony CMS event to save a customer order
<?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 / symphony-cms-caching-extensions.md
Created November 3, 2012 19:45 — forked from anonymous/gist:4008089
A guide to caching extensions (Symphony CMS) by Nick Dunn

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

<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>
<?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';
@DavidOliver
DavidOliver / SymCMS - Getting data notes.mkd
Last active March 29, 2019 09:02
Notes on getting data from within Symphony CMS

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
@DavidOliver
DavidOliver / data.parts.php
Created February 8, 2012 21:29
Custom data source for Symphony CMS
<?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