Articles tagged with php

How to Register and Use Custom PHP Functions Inside XSL

This article is not about justifying the use of PHP inside XSL. It is about how to do so if you need to or just want to. The case that I use as an example can be done easily in XSL without the use of a PHP function.

The title stresses custom PHP functions but you can also use this approach to enable the use of built-in PHP functions. A custom PHP function must be defined and registered before it is called by an XSL page template. A built-in function only has to be registered.

Read the full article.

How to Create a Custom Data Source in Symphony CMS 2

In Symphony a data source is the conduit between your content, which is stored in a database, and the web page you display to site visitors. It allows you to extract data from specified tables and to filter, sort and group that data before displaying it. Although Symphony offers considerable flexibility in defining data sources in the Symphony backend, you most likely will encounter situations where you would like to do a little more than Symphony offers.

A data source pulls from only one section. (A section defines a type of content, the fields that are used to collect the content and the data base tables where the content is stored. There is a one-to-one correspondence between fields and tables.) But suppose the content you want to display from one section depends on the content of another section, and suppose the dependency is more complex than a simple link, like linking comments to articles or articles to categories. A custom data source is one way to do this. You might be able to use two data sources to pull all the content from both sections and then do the merging with XSLT, but this could involve a lot of processing overhead, depending on the size of the content and the nature of the dependency between the sections.

Read the full article.