Dialogs Framework Basic Concepts

Dialogs Templates: List Templates

Updated: 21 Apr 2023


List Templates define both the presentation (HTML/CSS/JS) of information to be shown from a List as well as the selection (MySQL Where clause) of all or particular items from that List and the order (MySQL order by) multiple items will be displayed. Developers may create multiple List Templates for the same List, thereby creating different layouts of the same information and/or stipulating different subsets of the List items to display. List Templates may include other List Templates.

List Templates - v.8

  • Name Each list template should have a unique name. Names should start with "list_" and end with "." Example: "list_mylist."
  • Position (optional) Not particularly important to define for List Templates, but can be used to organize list templates if desired.
  • Search Form (optional) Holds html to create a search form for the list. The most common is:
    <form method="post" action="/a/KDpg_item_quick_chg.html" class="form-inline" role="form" _lpchecked="1">
        <input type="hidden" name="list_id" value="$KDlist_id">
        <div class="form-group">
            <label class="sr-only" for="searchString">Search List</label>
            <input type="text" class="form-control input-sm" name="searchString" value="<? $_SESSION[$KDlist_id]['searchString'] ?>" placeholder="Search">
        </div>
        <div class="form-group btn-group btn-group-sm">
            <input type="submit" name="submit" class="btn btn-primary" value="Search">
            <input type="submit" name="clearSearch" class="btn  btn-default" value="Clear">
        </div>
    </form>
  • List Template Content
    • List Header (optional) Holds the html that will appear at the top of a list - before any of the list items from the database. Commonly this is an opening div or ul tag.
    • Item Format The Item Format field contains HTML used to display just one list item. It will be used repeatedly, once for each item fetched from the database. Columns from the database table may be referenced using the $row variable like this: $row[column_name]. So, for example, $row[item_name] would show the value in the 'item_name' column from the database table. PHP functions and expressions may be used if encased within delimiters. Here are some other available variables which do not come from the database.
      • $odd_even contains either 'odd' or 'even', alternating between rows. Useful for alternate 'banding' of rows.
      • $row[treelevel] Contains a number representing the 'depth' of the item in treeview mode. Specifically it is the number of periods '.' in the list_sort field. So, A.1.c would be at level 2.
      • $row[treenav] Contains a link to expand or contract an item in treeview mode.
      • $item_count contains a number representing each row. The first row is 0, the second is 1, etc. This is useful for displaying lists in '3-up' format, etc.
      • $detail_link contains the url for a link which, when clicked, will replace the 'list view' (all items styled with item_format) with the 'detail view' of just that one item.
      • $detail_back_link contains a url for a link which, when clicked, will return to the 'list view' from the 'detail view'.
    • List Footer (optional) Holds the html that will appear at the bottom of the list, typically a closing DIV or UL field.
    • Message for Empty Lists (optional) If empty and there are no matching items to display, the List Template will not return ANY html/text. If this field is defined, it's contents will be returned.
    • Message for Errors (optional) What displays if the list returns a MySQL error. This will not trigger for PHP syntax errors.
  • List Template Setup
    • List Name Defines which list to display with the List Template.
    • Table Name (optional, rare) Typically the same as List Name; useful for comlpex SQL joins, etc.
    • Fields (optional) Useful for defining specific fields; useful for complex SQL joins, etc.
    • Where (optional) MySQL WHERE clause. Defines which items to show (if not all). Typically item_active=1 AND other restricting paramaters.
    • Sort The name of a field by which to sort results.
    • Limit by User List will be filtered matching the logged-in user item_id against the user_id field in the list.
    • Quickedit Allows the use of "Save and Next" buttons.
    • Debug Logs debugging information to the LOG list every time the list is displayed.
    • Searchable Items will be indexed for search.
    • List ID (optional) Useful for complex SQL joins, etc.
    • Group By (optional) Useful for complex SQL joins, etc.
    • Having (optional) Useful for complex SQL joins, etc.
    • Stats SQL (optional) SELECT sum( some_numeric_field) AS sum FROM some_table_name
  • List Template Paging
    • Paging Turns paging of results on.
    • Tree View List allowed to use expanding tree view.
    • Limit (optional) Limits the number of items that will be displayed on each page.
    • Paging format Defines the interface for navigating multiple pages of a result set if a Limit has been set. There are usually four controls: First Page, Previous Page, Next Page, and Last Page. These variables are available:
      • $oneTwoThree - 1 2 3 4 5 format
      • $href1,$href2,$href3,$href4 - First, Prev, Next, Last hrefs for do-it-yourself anchor links.
      • $link1,$link2,$link3,$link4 - First, Prev, Next, Last links with spans and classes ready for CSS.
      • $page_no - Number of the current page.
      • $total_pages - Total number of the pages.
      • $total_records - Total number of the items.
    • Detail format Contains html which determines how a single list item will be displayed when the list is in Detail Mode. A list goes from List Mode to Detail Mode when the user clicks the 'Detail' link created using the $detail_link variable in the 'Item Format' field. All of the $row variables are available as well as $detail_back_link which contains the url for a link which, when clicked, will return to the list view from the detail view.
      NOTE: While this detail view method is still available for use, because of SEO concerns it is usually better to use Phantom Pages for detail views on list items.

List Templates - v.7

  • Name Each list template should have a unique name. Names should start with "list_" and end with "." Example: "list_mylist."
  • Position (optional) Not particularly important to define for List Templates, but can be used to organize list templates if desired.
  • Search Form (optional) Holds html to create a search form for the list. The most common is:
    <form method="post" action="<? $this->site_dir ?>/a/KDpg_item_quick_chg.html">
        <input type="hidden" name="list_id" value="$KDlist_id" />
        <input type="text" name="searchString" value="<? $_SESSION[$KDlist_id]['searchString'] ?>" />
        <input type="submit" name="submit" value="Search" class="button" />
        <input type="submit" name="clearSearch" value="Clear" class="button" />
    </form>
  • List Header (optional) Holds the html that will appear at the top of a list - before any of the list items from the database. Commonly this is an opening div or ul tag.
  • Item Format The Item Format field contains HTML used to display just one list item. It will be used repeatedly, once for each item fetched from the database. Columns from the database table may be referenced using the $row variable like this: $row[column_name]. So, for example, $row[item_name] would show the value in the 'item_name' column from the database table. PHP functions and expressions may be used if encased within delimiters. Here are some other available variables which do not come from the database.
    • $odd_even contains either 'odd' or 'even', alternating between rows. Useful for alternate 'banding' of rows.
    • $row[treelevel] Contains a number representing the 'depth' of the item in treeview mode. Specifically it is the number of periods '.' in the list_sort field. So, A.1.c would be at level 2.
    • $row[treenav] Contains a link to expand or contract an item in treeview mode.
    • $item_count contains a number representing each row. The first row is 0, the second is 1, etc. This is useful for displaying lists in '3-up' format, etc.
    • $detail_link contains the url for a link which, when clicked, will replace the 'list view' (all items styled with item_format) with the 'detail view' of just that one item.
    • $detail_back_link contains a url for a link which, when clicked, will return to the 'list view' from the 'detail view'.
  • List Footer (optional) Holds the html that will appear at the bottom of the list, typically a closing DIV or UL field.
  • List Name Defines which list to display with the List Template.
  • Table Name (optional, rare) Typically the same as List Name; useful for comlpex SQL joins, etc.
  • Fields (optional) Useful for defining specific fields; useful for complex SQL joins, etc.
  • Limit (optional) Limits the number of items that will be displayed on each page. If a limit is set then Paging Format should also be defined as it presents the user with the means to access each page of the result set. Example:
    <a href="$link1" >First</a>
    <a href="$link2" >Prev</a>
    Page $page_no of $total_pages
    <a href="$link3" >Next</a>
    <a href="$link4" >Last</a>
    Total Records: $total_records
  • Where (optional) MySQL WHERE clause. Defines which items to show (if not all). Typically item_active=1 AND other restricting paramaters.
  • Sort The name of a field by which to sort results.
  • List ID (optional) Useful for complex SQL joins, etc.
  • Group By (optional) Useful for complex SQL joins, etc.
  • Having (optional) Useful for complex SQL joins, etc.
  • Stats SQL (optional) SELECT sum( some_numeric_field) AS sum FROM some_table_name
  • Message for Empty Lists (optional) If empty and there are no matching items to display, the List Template will not return ANY html/text. If this field is defined, it's contents will be returned.
  • Paging Format Defines the interface for navigating multiple pages of a result set if a Limit has been set. There are usually four controls: First Page, Previous Page, Next Page, and Last Page. These variables are available:
    • $oneTwoThree - 1 2 3 4 5 format
    • $href1,$href2,$href3,$href4 - First, Prev, Next, Last hrefs for do-it-yourself anchor links.
    • $link1,$link2,$link3,$link4 - First, Prev, Next, Last links with spans and classes ready for CSS.
    • $page_no - Number of the current page.
    • $total_pages - Total number of the pages.
    • $total_records - Total number of the items.
  • Detail Format. Contains html which determines how a single list item will be displayed when the list is in Detail Mode. A list goes from List Mode to Detail Mode when the user clicks the 'Detail' link created using the $detail_link variable in the 'Item Format' field. All of the $row variables are available as well as $detail_back_link which contains the url for a link which, when clicked, will return to the list view from the detail view.

Developers seeking to embed PHP code in Dialogs List Templates should read the Knowledge Base entry Embedding php in List Templates

 

Next: Dialogs Templates: Nav Menus

LinkedInFacebookYouTubeTwitter