List Viewer Options
List Viewers have options at the top you can customize.
They look like this:
| <!--
STEP1: Load Record List (Paste this above other steps)
--> |
| <?php |
| require_once
"/www/htdocs/cmsAdmin/lib/viewer_functions.php"; |
| $options
= array(); |
| $options['tableName']
= 'article'; |
| $options['titleField']
= 'title'; |
| $options['viewerUrl']
= 'articlePage.php'; |
| $options['perPage']
= ''; |
| $options['orderBy']
= 'featured DESC, date DESC, title'; |
| $options['pageNum']
= ''; |
| $options['where']
= ''; |
| $options['useSeoUrls']
= ''; |
| list($listRows,
$listDetails) = getListRows($options); |
| ?> |
| <!--
/STEP1: Load Record List --> |
All of these settings are automatically generated and generally
don't need to be modified. Here's what each of them do.
require_once
".../lib/viewer_functions.php";
This tells the viewer
where the program is located. The Viewer Generator automatically
figures out the right
path. If you move files around on your server you'll need
to update this page.
tableName
This is the MySql
database tablename that the viewer will load records from.
If you change the Table
Name (in Admin > Section Editors), you'll need to update
it here as well.
titleField
This specifies one
or more fieldnames to use to create a page link for each
record. The first non-blank field value will be used to
create a link such as this:
| pageViewer.php?article_title_here-123/ |
You can specify multiple
fields like this:
| $options['titleField']
= "filename, title"; |
This would check the
'filename' field for a value first, then the title field.
Note that only the number on the end is used to identify
the record, so even if the title changes, all previous links
will still work.
viewerUrl
The filename or full
URL used when creating links to the page viewer.
perPage
The number of records
to show on the page. Defaults to ten.
| Tip:
If you want to show ALL the records, set this to a high
value such as 999999. |
orderBy
A comma seperated
list of fields used to sort the list of records (example:
author, title). Here are some
common special sorting commands:
| • |
fieldname DESC - The suffix "DESC" will sort the
field in descending order (i.e. backwards). Added
to a date fieldname, this will sort the newest records
first. |
| • |
fieldname+0 - sorts the field as a numeric value.
Use this suffix if you are sorting numbers, but the
sorting is coming out in a strange order (1, 2, 20,
21, 3, 4, 45, etc.). |
| • |
RAND() - Sorts the results in a random order. The
results will be randomized every time the viewer is
loaded. |
| Tip:
orderBy is actually just a standard MySQL ORDER BY clause.
If you are comfortable with MySql you can whatever conditions
you might need here. |
pageNum
The page number of
results to display. This defaults to the page number from
the url (eg: listViewer.php?page=2)
or 1.
| Tip:
Set this to '1' if you always want to show the first
page or if you have multiple viewers on the same page
and you want to ignore the ?page=N value. |
where
If you are comfortable
with MySQL this field lets you specify your own custom MySQL
WHERE clause. If this
field is blank then the WHERE condition is generated from
search field specified in the
form or url (see Search Engines).
| Tip:
Set this to '1' to show all records and ignore automatic
search fields (such as when you have multiple viewers
on one page and one is using searches to filter results). |
useSeoUrls
When set to '1' this
enables search engine friendly urls for page links. They
look like this:
|
articlePage.php/Hello_World-1/ |
|
articleList.php/page-1/ |
| articleList.php/color-blue/page-1/ |
instead of this:
|
articlePage.php?Hello_World-1/ |
|
articleList.php?page=1 |
| articleList.php?color=blue&page-1 |
This is not supported
on all web servers.