Recent Articles

How to Display Next and Previous Article Links in Symphony CMS 2

When a single content entry is displayed on a web page it is often desired that links be provided to the next and previous chronological entries. (This can apply to any content with a date field, not just articles.) This article attempts to explain how this can be done using a single custom data source. It is difficult (impossible?) to do this using only the backend data source creator.

The following assumptions are made in the remainder of this article:

Read the full article.

How to Display Static Content Within the Symphony CMS

There have been several inquiries in the Symphony Forum about displaying static content within the Symphony content management system. I will attempt to describe three basic approaches to accomplishing this. There are many more variations on these approaches than I cover here, but hopefully this will be enough to get Symphony beginners started. The three basic approaches are:

  1. Use a conventional section, data source and page to define, store and display the static content.
  2. Use a static XML data source to define and store the content and a conventional page to display it.
  3. Use only a page to define, store and display the static content, placing all the content in the page's XSL file as HTML.

Read the full article.

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 Tag Cloud Using a Custom Data Source

I promised to follow up a previous article with a few examples like this one. If you haven't already, and you are new to custom data sources, you should read that article before reading this one. This is provided as an example only; it is not necessarily the best way to implement a tag cloud.

If your site content includes a section with a Tag List field (zero, one, or more words or phrases separated by commas) you might want to display the tags along with their frequency of use. One way to do that is to just list the tags along with a count of all the section entries that contain the tags. Another is to list the tags without the count but set the font size in proportion to the frequency of use. I use the latter method, called a tag cloud, on my archives page. Either way you will need to extract from your database a list of all the tags used and a count of the entries that contain the tags.

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.

How to Pre-Enter Author Data in Comment Form

I wanted a new feature for my blog site that fills the Author, Email and Website fields of my comment form with data collected from a previous comment. That is, if a visitor has made a comment before, the visitor won't have to fill in those fields on the next comment (provided that the visitor is using the same computer). I accomplished this by placing a cookie on the visitor's computer which holds the visitor's name, email address and website URL, and then retrieving that information before a comment form is displayed.

The cookie is created in my save-comment event. The last six lines in its __trigger() function now look like this:

Read the full article.

Sessions and Cookies

The purpose of this article is to describe how PHP Sessions and Cookies are used in Symphony CMS and how that affects the user of a website powered by Symphony. I won't get into great detail about the general usage of sessions and cookies because Googling those terms will turn up several good tutorials.

When a new visitor views a Symphony powered site a cookie is placed on the visitor's computer, a session record is stored in the site database and some parameters are set. The session and cookie are related through a unique key that is stored in both. The cookie is set to expire two weeks from the time it is created. The session, however, doesn't contain an expiration date. It just keeps a record of the last time the visitor loads or refreshes a page on the site. The session record also contains a visitor's username and password if the visitor has logged in.

Read the full article.