Hook for a List of Pages

This is a user-created module named PageListForGoToPageHook. The purpose is similar to that of GoToPageHook except that this hook will accept a list of pages for a tag. See also: Hook for "Go To Page" calls

If GoToPageHook and PageListForGoToPageHook both exist, GoToPageHook takes precedence and PageListForGoToPageHook does nothing.

Otherwise, this hook will take a tag names and returns a custom list of pages and a Boolean value. The Boolean value tells whether the returned custom list or the default list should be displayed. The custom list can return 100 pages at maximum, and can only return pages. If the returned list contains more than 100 pages, nothing will be displayed. If an item that is not a page is returned, the particular item will be ignored.

Procedure:

Create a module within your application named PageListForGoToPageHook

When declaring this module in AppRoot.SRC, do not add it to any class.

  PageListForGoToPageHook Module "PageListForGoToPageHook.SRC";

The module must take two parameters: TagNames, pPageList .

  • TagNames is an array containing the name or names the tag(s) to which you are navigating.
    (Users may select more than one tag before issuing a Go To Page command.)
  • pPageList is an output parameter and must be a structure specifying the pages to open.

 

The module must have a return value. Return FALSE if the standard "go to page" action should be taken following the code within your hook module. Return TRUE to suppress the standard action, such as when the module is handing page navigation on its own.

The module works by populating a structure, which is then used to present your selection of pages to the user.

The definition of this structure follows:

  {Public} GetPagesForTagsHookPageInfo STRUCT [
    Name                      { Page name of the custom page                  };
    Parms                     { Parameters needed by the custom page          };
    Label                     { Label of the custom page                      };
  ];

Parms should be a local array holding the parameters that the selected page will need.

Label is a text value. It can be a phrase ID.

You might create both Parms and Label using information from the selected tag. It is common but not necessary to use information from the selected tag to populate both variables.

The maximum number of pages that can be presented is 100. Invalid entries for pages will be ignored.

Example:

(
  TagNames;
  PagesForTagsHook;
)
[
  Name                      { Page name of the custom page                  };
  Parms                     { Parameters needed by the custom page          };
  Label                     { Label of the custom page                      };
]
Main [
  If 1;
  [
    IfElse(TagNames[0] == "MyTag", Execute(
      Parms     = New(1);
      Parms[0]  = MyTag;

      *PagesForTagsHook    = New(3);
      (*PagesForTagsHook)[0] = \PageTagRefMgr.GetPagesForTagsHookPageInfo("MyPumpPage", Invalid, "Custom pump page");
      (*PagesForTagsHook)[1] = \PageTagRefMgr.GetPagesForTagsHookPageInfo("GenericPumpPage", Parms, "Standard Page");
      Return(TRUE);
    );
    { Else }
      Return(FALSE);
    );

  ]
]