Skip to content

nickdunn/parametrisator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parametrisator

  • Version: 1.2
  • Author: Marcin Konicki (http://ahwayakchih.neoni.net)
  • Build Date: 2 January 2012
  • Requirements: Symphony version 2.2 or later.

Overview

Parametrisator allows you to use XSLT and XPath to select data from data-source generated XML, turn it into parameters and add to the parameter pool used by all data-sources. It works with any type of data-source distributed with Symphony, as long as it is editable and returns XML in $result variable.

You can select single XSLT utility for any data-source to "parse" XML data before it will be turned into parameters. You can specify one or more XPaths for any data-source. Each of those XPaths will generate one additional parameter.

Original XML data will stay untouched. It will be used by pages and utilities as usual.

Installation

  1. Upload the 'parametrisator' folder in this archive to your Symphony 'extensions' folder.
  2. Enable it by selecting the "Parametrisator", choose Enable from the with-selected menu, then click Apply.

Changelog

  • 1.2 Bugfix release.
  • 1.1 Official release. Added support custom parameter names and for passing XML data through additional XSLT, just before data is selected into parameters.
  • 1.0 Internal release.

Usage

  1. Create data-source that should output additional parameters based on XML data it generates.
  2. If it is section data-source, make sure to select "Included Elements" that you want to use as parameters.
  3. Scroll down to "Parametrisator" and enter XPath(s) that will select data. You can select XSLT utility, that will be used on XML data just before it is passed to XPath(s).
  4. Save changes.

XPath(s) should select data from data-source root element. For example, if data-source is called "Articles", its root element will be "articles". To select title handles of "articles" as parameter, use: /articles/entry/title/@handle (and remember to select "title" field as one of "Included Elements"). You can use other parameters in XPath, e.g., /articles/entry/title[@id={$url-id:$ds-other-source-id:42}]/@handle.

Known problems

Interface used on data-source edit pages is JavaScript-only.

If you want to use generated parameters to filter other data-sources, you have to make sure that they are generated before those data-sources are called. For example, if "Articles" has field called "bibliography" which is text area with list of names, and there is section "Books" with field "title", and you want to select Books that were listed in Article:

  1. Create data-source "articles", select "bibliography" as one of "Included Elements"
  2. Enter name: "bibliography-handles". Enter XPath like this (it depends on how bibliography text will be formatted, of course): /articles/entry/bibliography//li[class="book"]/@handle in "Output More Parameters" setting.
  3. Create data-source "books". 4a. Filter it by "title" field with following expression: {$ds-articles:$ds-articles-bibliography-handles} (if "articles" data-source has "none" selected in "Use Field" parameter output setting), 4b. or filter it by: {$ds-articles-bibliography-handles} and set "Required URL Parameter" to $ds-articles (if "articles" data-source was set to output at least one standard parameter too).

When Symphony checks for dependencies, only "standard" parameter names are checked. So $ds-articles-bibliography-handles will not be recognized as a dependency and Symphony may execute data-sources in incorrect order. If "standard" parameter is mentioned in at least one of the filters, required parameter or sorting setting, Symphony will recognize it as dependency, even though that parameter may be empty (or never generated by any data-source).

Things to implement in future

    • Obsolete (Symphony 2.3+ can output multiple fields as parameters): Select between XPath and regular field output in case of section data-source.
  1. ? If/When Symphony will leave <!-- EXTRA --> marker for DatasourcePreCreate and DatasourcePreEdit delegates (removing it AFTER those delegates return), we can drop tokenization of whole data-source code, and inject our code in a much simpler way.
  2. ? It probably would be better to build interface for data-source on server side, so it would not require JavaScript to be enabled on browser side.

About

Symphony 2 CMS extension: output additional parameters from any type of data-source

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 78.7%
  • JavaScript 21.3%