Search

A new Extension, “Global Parameter Loader” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

Having trouble while adding custom page parameters to be used for DS filtering? Want to evaluate some PHP code and add the results to a page parameter? Previously, this was not possible, but now you can with the amazing:

Global Parameter Loader

Version: 1.1.8
Author: Carsten de Vries <carsten@vrieswerk.nl>
Build Date: 5 July 2009
Github Repository: http://github.com/carsten/globalparamloader/tree/master
Requirements: Symphony 2

Allows you to add sets of parameters to Symphony’s parameter pool while excluding specified pages. Furthermore, valid PHP code is parsed before adding the parameter to the parameter pool.

Warning: safe evaluation has not been added yet. Do not enable this extension if you are not absolutely sure that your Symphony installation is secure.

Installation

  1. Upload the ‘globalparamloader’ folder in this archive to your Symphony ‘extensions’ folder.

  2. Enable it by selecting the “Global Parameter Loader”, choose Enable from the with-selected menu, then click Apply.

Usage

  1. View the Blueprints > Global Parameters page to add, edit, and remove Parameter Sets.

  2. Click the create new button to create your first Parameter Set. Give the Parameter Set a name.

  3. Click Add item to add a parameter. At least one parameter must be defined for each set, and each parameter must have a name.

  4. Choose any pages you wish to exclude from this Parameter Set. Currently, at least one has to be chosen.

  5. Click the Create Set button. Now, go see your newly added parameters at your pages in Parameter debug mode (add ?debug=params to the page URL).

Example A: Add user IP address to the parameter pool

  1. Add a parameter with parameter value:

    return ($_SERVER[‘REMOTE_ADDR’]);

Example B: Add domainname and extension to the parameter pool

  1. Add a parameter with parameter value:

    return array_pop(explode(‘.’, $_SERVER[‘SERVER_NAME’], 2));

Acknowledgments

The Symphony development team and all contributors for such an amazing content management system. Rowan Lewis for both his emailtemplatefilter and globalresourceloader extensions, on which this extension is based. Marcin Konicki for telling me to reinstall this extension to make it work.

Download

carsten -

this is going to be great! thank you so much for pulling this together!

Nice one carsten. Can you give a few examples of when this Extension would be used?

You can use this extension to display certain page content or data on certain pages.

For example, you might want to include a Who's online list on some pages but not on others. Now, create a new parameter set with param "include-who-is-online" with value "yes" and exclude the pages you don't want the widget on. Then, in your master.xsl put <xsl:if test="$include-who-is-online = 'yes'">who is online code here</xsl:if> to display it on all pages except the ones that you have excluded.

Also, you might want to filter some entries that should not be on certain pages but should be included on other pages. For instance, I have entries in Swedish and English and I only want the Swedish entries displayed on Swedish pages (but, English entries too since most Swedes are likely bilingual). Now, in the entries section I will specify the language of an entry with a dropdown menu so each entry will have it's language set. Set up a datasource and filter by language {$include-language}. Include the datasource in your English and Swedish pages, and now create a new parameter set with parameter include-language and value english. Now, exclude all Swedish pages. The entries on your English pages will only contain entries in English, while entries on your Swedish pages contain both languages.

@carsten: Great. I've been looking for something like this, for separating english and swedish content.

This looks really useful. Thanks, looking forward to trying this out tonight.

Released version 1.1, added functionality to evaluate valid PHP code in parameters.

See opening post for the latest instructions and some examples.

So if you're executing php functions, could you use this extension to set headers, just by adding a param with header() in it?

Yes.

Edit: I have just fixed the bug that prevented page exclusion.

Now, it is possible to create a page and assign a parameter to it by excluding all other pages. This can be a header too, so if you put header("Location: http://www.google.nl"); as parameter value, this will redirect the page that is not excluded to google.

I want to use this to serve the user his language of choice (based on browser settings) currently I am using:

return ($SERVER['HTTPACCEPT_LANGUAGE']);

which outputs;

en-us

The form of this return will ALWAYS be like; (in order of preference);

en-us-es-....

What offcial documents/iso shoudl I use, and what template to go from shorthand to full written language?

However I wonder if I cant clean this up in php, this doesnt seem to work;

substr($SERVER['HTTPACCEPT_LANGUAGE'], 0, 2);

Also what woudl be the best methodology of offering the users first language of choice, if it is available, or second,... and so on.

Have you tried return(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)); ?

I don't know how many users would actually enter around 5 preferred languages, so maybe you can create the following global parameters: lang1, lang2, langN, with values:

$lang = explode('-', $_SERVER['HTTP_ACCEPT_LANGUAGE']); return($lang[0]);
return($lang[1]);
return($lang[N-1]);

Alternatively, you can save all languages to one parameter and then split the values into elements using xslt.

@carsten: Should this extension work with Symphony 2.0.2 (stable release)? PHP statements (like in your examples) are not executed for me, but displayed as text strings.

It should work with Symphony 2.0.2, I am running it on my own website.

What does return ('test'); return as param?

This returns test – as expected. But if I try return ($SERVER['REMOTEADDR']); it returns the string return ($SERVER['REMOTEADDR']);

Try $_SERVER?

I actually get Array if I try return ($_SERVER);. Hmmm

OK, I found the problem. It’s in copying examples without thinking. Actually this works:

return ($_SERVER['REMOTE_ADDR']);

While the example in the initial post has actually two typos:

return ($SERVER['REMOTEADDR']);

Thanks, Carsten and Nick, for pointing me to the right direction.

Hmmm, I don’t manage to get POST data as params. I tried s.th. like:

return ($_POST['fields[title]']);

Is this a restriction of the extension?

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