Search

Hi All,

So I kinda hit my first conceptual roadblock with Symphony. The core config settings are stored in the config file & editable via the Configuation Settings extension, should you want it (I for one think this should be core). But how do you add your own global config settings?

I’m asking this as both a theoretical and practical question. What is the conceptually correct approach and which works in practice?

Would you:

  1. Add your own settings to the array in config.php
  2. Create a section called “config” which takes individual key-value pairs
  3. Create an extension and add your options to the system > preferences screen
  4. Some other way I haven’t discovered/thought of

The first would seem like a hack, the second awkward and the third a lot of work? All however seem like they may fit Symphony conceptually.. depending on how you perceive the concepts :D

Advice on this would be welcomed :)

Eris

This should normally be done by an extension. If you want to see how, take a look at my Textformatter Labels. It is adding six text input fields to the config! Reading the config (arrays) is even easier, as simple as:

$config = $this->_Parent->Configuration->get();
$bar = stripslashes($config['foo']['bar']

But how do you add your own global config settings?

What kind of configuration settings do you want to store? I’m curious because I never had the need to add my own configurations.

Oooh allsorts no doubt! Not really got specific examples.. I’m just trying to see where the limits are should I try to use Symphony in the wild.

Sorts of things I might want to make “global config” off the top of my head: - access credentials for external APIs - items per page or other numerical settings - system email addresses

OT: Why do lists display properly in the editor but not in the posted comment?

But how do you add your own global config settings?

See the Textformatter Labels extension (as one example). Take a look at the code.

OT: Why do lists display properly in the editor but not in the posted comment?

Should work if you use Markdown!

OT: Why do lists display properly in the editor but not in the posted comment?

It was the “Would you” above the list, needed a double line break for Markdown to realise the following was a list.

But how do you add your own global config settings?

Those sorts of settings seldom change once you’ve added them, so that’s why there’s no core UI for modifying them. I’d suggest #1, just add your own key to the config array.

In your own custom code you could access them in one of two ways:

  • in Symphony code (custom Data Sources etc) you can use the Configuration class
  • in your own scripts, just include config.php and you’ve got the array

Once you’ve added them to config.php yourself, the values should be editable with the Configuration Settings extension if you want to tweak ‘em.

The tricky part is if you want to get these values into your XML to use them in XSLT. You’ll need to create a custom Data Source that iterates over your added key to the config array, and outputs whichever values you want as XML.

OT: Nick’s old gravatar is back — isn’t it cool?

@michael-e

Totally. The new one had left me confused and disoriented.

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