Using TV Output Widgets
Template Variable Output Widgets format the TV's content for display on the final web page. These are optional; you can simply use the raw content of any TV. You can also create your own custom output "widgets" using snippets. This is my preferred way of dealing with TV output; I find the built-in widgets to be rather limited. There is an excellent article in the wiki on how to do this.
The built-in output widgets' formatting functions are in the /manager/includes/tmplvars.format.inc.php file.
The output widgets that depend on javascript use the mootools.js and the custom moodx.js libraries found in manager/media/script. A link to these libraries will be inserted into the head of the document. This can cause conflicts with other javascript libraries that you may include for your own functionality; in this case it would be better to use a snippet to provide custom TV output formatting.
The Built-in TV Output Widgets
There are 14 built-in output widgets to format the TV's content. Most of them have a list of parameters to control their output.
- Data Grid - format tabular data from a number of sources.
- Floater - inserts the javascript code for creating a floater with the TV's input.
- Marquee - creates a scrolling marquee.
- Rich Text - creates a Rich Text Editor enabled textarea field with the TV's content inserted.
- Ticker - makes a ticker-type display of your input data.
- View Port - creates an iframe for displaying the TV's value.
- HTML Entities - converts the TV's value to HTML entities.
- Date Formatter - displays a date with the given format using the PHP mktime() or strtotime() functions to convert the TV date value to a UNIX timestamp, then uses strftime with the given parameters to convert the timestamp to a date/time string.
- Unixtime - converts a human-readable date and time to a Unix timestamp. This can be useful since the Date input type stores the date as day-month-year hour:minutes:seconds.
- Delimited List - creates a list whose items are separated by the given delimiter.
- HTML Generic Tag - surrounds the TV's content with the given HTML tags.
- Hyperlink - creates a link with the given attributes.
- Image - surrounds the TV's image filename with
tags. - String Formatter - applies string formatting options such as uppercase and lowercase.
If no widget has been selected, the TV's value will be ouput exactly as it was entered in the input fields. If the input type was radio buttons or check boxes, their values are converted to a string with the values separated by || characters for easy custom handling.
Comment On This Article
Do you find something unclear? Did I miss something or get something wrong? What do you like or not like about this chapter? Please do not ask for help here; use the forums if you need help.