Search

Hi, guruz. How do u usually solve the following task. I need to get the value of symphony static section frequently from the “outside” php-script. Or maybe it’s better to update some ‘ini’-file automatically upon section edit in the backend (thus avoiding “heavy” db-operations at all).

If your PHP savvy and love XML, you could go this (long) way about it:

  • Create a Page and give it an XML type
  • Create a Datasource to output the value and attach it to that page
  • Use XSLT to pretty the value however you want
  • Create a Dynamic DS that reads your Page and set the Cache really high
  • Attach that to another Page

In your PHP you can CURL that page with the Dynamic DS and read the XML.

It really depends what value you are after though. If it’s something really simple, like the results from one field, you could write custom SQL to query the database directly for that value.

I prefer the second solution :-) But don’t understand the inner logic of symphony. I’ve found the value needed in table ‘symentriesdata_114’. What does this number mean? Is it permanent or subject to change?

Is it permanent or subject to change?

Permanent. It is the internal ID of the field (in the sym_fields table).

Nick, Brendo, thanks for your valuable replies. One last question. How can i hijack the Save event in sections editor? in my case instead of retrieving data from sql periodically to be able to do some stuff on every change in a section.

By change in a section, do you mean the actual structure of the Section, or when a new Entry is created in a section?

Have a look at the delegates list. There’s quite a few for the latter, the former not so much.

Suppose EntryPostEdit is what i need (when Section structure stays untouched, just content modification)

So AFAIUnderstood what i need is to write kind of “dumper”-extension, that ‘ll create/update ini-file upon every edit in my static (or usual) section.

You will need to create an extension comprising a single extension.driver.php file within which you subscribe to the EntryPostCreate and EntryPostEdit delegates which will provide you with the Section and Entry objects, plus the $_POST array of field data.

Have a quick look at the Entry Versions driver and you’ll see what I mean:

  • define your extension class (named the same as the extension folder)
  • define an about() array providing meta data
  • add a getSubscribedDelegates() method returning an array of delegates you wish to subscribe to, with their callback function names too
  • create a public method for each callback, which receives a single argument $context

Then go to System > Extensions and enable the extension, which will bind your delegate subscriptions. Each time the subscription array changes you’ll need to re-enable the extension.

Delegates are partially documented on the Delegates page but there aren’t any tutorials yet to show you how to use them in practice. In Symphony 2.2 (coming out near or after Christmas) we’re hoping to have the delegates fully documented.

Wow, thanks a lot, Nick. Examples is all we need :-) I’ll try to experiment with the help of your little tutorial as soon as possible.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details