Overview

Dollar Functions are primarily used to add dynamic content to your website. As a trivial example, if you want to show the current date and/or time on a page, since this information changes constantly, you would use a dollar function to generate this information dynamically.

Internally, dollar functions have access to all of the information available related to your website so they can be very sophisticated but most are very simple to develop and use.

Parameters

Dollar functions theoretically can accept any number of parameters but most only require a small number of parameters. Usually, the critical or required parameters are defined first, followed by optional parameters that are generally defaulted. String parameters do not have to be encased in quotes unless the parameter value contains one or more commas since the comma is used as a parameter separator.

In most cases, you will learn about parameter values by entering the function name on a page including the trailing brackets () then placing your cursor on the name and using Crtl + g to get help entering the function parameters. The resulting form will allow you to enter the parameters for the dollar function and, in most cases, test the function output and return the completed dollar function to its container.

Nested Parameters

Dollar functions can be nested to any depth, this can be very useful since it allows parameters to your dollar functions to be supplied by other dollar functions. Consider an example where a layout may embed one of two possible subpages depending on which page is being shown. In this case the layout could include these nested dollar functions:

$page($iparm(subpage,default_subpage))

The iparm function is used to obtain the value of an internal parameter defined for the current page. This function can accept a default to be used when the parameter is not defined for a given page. This nested sequence would embed a subpage called default_subpage except for pages which define an alternate subpage name in their internal parameters.

Postponing Dollar Function Resolution

By default, when dollar functions are used as parameters to other dollar functions, these parameter values are resolved (expanded) before calling the container dollar function. Occasionally, you want to have the nested dollar functions resolved after the containing dollar function is processed. This can be achieved by using the string {DOLLAR} instead of the $ sign. As an example, consider the following nested dollar function which repeats a page using a for loop structure:

$for(1,$session(number_of_packages),'{DOLLAR}page(package,package=%1)',1)

Notice that the for loop is intended to repeat a page called package a certain number of times depending on the value of the session variable $_SESSION['number_of_packages']. If the package page was resolved before processing the for loop, the identical html code would be repeated several times. This would generally repeat the same scalar form variables several times. By resolving these later, the system would process the forms independently and detect that the same form variables are used more than once and would create the form fields as array fields.

Help Index

GenHelm Architecture GenHelm Architecure.
Why GenHelm? Summary of the GenHelm methodology.
Getting Started Learn how to start a new website.
Naming Conventions Naming web pages and other items.
Common Web Page Fields Descriptions of fields that are common to all page models.
Layouts Defining codeframes and layouts.
Styles and Scripts Descriptions of fields that are common to all page models.
Meta Tags How to configure meta tags for your site and specific pages.
Dollar Functions General information about dollar functions.
Navigation Tips Navigation Tips and Techniques
Favourite Icons How to configure favorite icons for your site.
Blog Maintenance Blog and post administration.
Direct Command Help Help for the direct command field.
Programming with GenHelm Writing programs that interact with the GenHelm framework.