ft_get_dhtml_page_nav

This function is the DHTML counterpart of the ft_get_page_nav function defined above. It provides exactly the same functionality to the user - displaying the same « 1 2 3 ... links - but instead of requiring a page refresh when a link is clicked, it hides and shows the appropriate section from the page. For this function to work, every page of the data has to have been loaded into the page, and only one of which is displayed at any time.

Using this function instead of ft_get_page_nav can be a good or bad approach, depending on your data set: it's primarily a question of volume. If you have a large amount of data to show, I wouldn't recommend using this. It will require you to load everything into the page - which can be extremely time consuming. It's really intended for situations that entail smaller data sets; for example, it's used to display pagination on the main Forms and Clients pages, since there will rarely be > 100 results (forms of clients) of either.

The function is called in your PHP, like so:

$page_vars["pagination"] = ft_get_dhtml_page_nav($num_results, $num_per_page, $page);

The function parameters are the following:

  1. the number of results in the total result set (required)
  2. the number of lines that appear per page (required)
  3. the current page number (required)

The "pagination" key has to be passed to the template via the ft_display_module_page function, like so:

ft_display_module_page("your_template.tpl", $page_vars); // where $page_vars contains "pagination"

In your template just use the $pagination variable to display it:

{$pagination}

You also must include /global/scripts/general.js in your template page. That contains the JS used to hide/show the pages.

From an HTML standpoint, the function works by detecting nodes in your page that have IDs of the form page_X - where X is a number corresponding to each page - and hiding and showing them depending on what's selected. e.g. if you just clicked "4" in the pagination links, it would (a) hide whatever page ID is currently selected (defaults to 1), and (b) show the element.

Figuring out the template logic can be a bit tricky, so I'd suggest taking a look at the /themes/[any theme]/admin/clients/index.tpl and/or /themes/[any theme]/admin/forms/index.tpl templates. They provide a couple of real-life examples of how to get it going.

Edit Page