Search

Hi,

I would like to be able to set values in the admin interface that i can re-use like the email address and phone number. So, for example if the site email changes i can change it in one place and it updates site wide.

I was thinking i could create a section called ‘constants’ with 2 fields, ‘name’ and ‘value’. But how could i reference the ‘value’ field in the XSLT ?

I hope I’ve been clear

Thanks

You could define these as variables in your master.xsl:

<xsl:variable name="email" value="'user@domain.com'" />

If they aren’t going to change often, there doesn’t seem to be much value in adding them into a Symphony section I don’t think.

Or, create your section as described, and attach a Data Source to every page. In XSLT you could create a key in your master template (so it becomes globally accessible by all other templates) which provides a quick lookup to the XML.

See: Parameter in selector

For example, this mightwork.

XML like:

<constants>
    <entry id="123>
        <name handle="email">Email</name>
        <value>user@domain.com</value>
    </entry>
</constants>

Create a key:

<xsl:key name="constants" match="/data/constants/entry/value" use="../name/@handle"/>

And use it:

<xsl:value-of select="key('constants', 'email')"/>

This is from memory so might not work first time…

A couple useful extensions for this (in case you do create a section):

Custom Preferences

Global Resource Loader

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