Ferreteria/v2/usage/pages: Difference between revisions
(explanation and sample code for action links) |
m (9 revisions imported: moving this project here) |
||
(4 intermediate revisions by one other user not shown) | |||
Line 38: | Line 38: | ||
$arActs = array( | $arActs = array( | ||
new clsActionLink_option(array(), // an "edit" link | new clsActionLink_option(array(), // an "edit" link | ||
'edit', // | 'edit', // link key (value) | ||
'do', // | 'do', // group key (name) | ||
NULL, // | NULL, // display when off | ||
NULL, // | NULL, // display when on | ||
'edit this supplier' // | 'edit this supplier' // description (shows as hover-over text) | ||
), | ), | ||
new clsAction_section('Manage'), // a static subsection -- just shows the text | new clsAction_section('Manage'), // a static subsection -- just shows the text |
Latest revision as of 16:46, 22 May 2022
About
Pages in Ferreteria handle execution of various processes to build a page, including form input handling and rendering of output.
An application will generally create their own page class descended from one of these classes, depending on what functionality it wants.
When URL translation is needed from a Page object (e.g. ParsePath()), the object passes the request over to menus.
Files
Classes
- clsPage (abstract) - default page execution, stub for automatic email when exception thrown; app, skin, and data objects
- clsPageBasic (abstract) - handles exception-email generation
- clsPageLogin (abstract) - provides login forms (inheritor must call them, though) and admin menus
- clsPageBasic (abstract) - handles exception-email generation
Processes
Page Creation
The basic sequence of page component creation as defined in clsPage is:
- $this->ParseInput();
- $this->HandleInput();
- The application will typically implement this as something like:
- $this->BuildMenu();
- $this->MenuNode_Init();
- $this->TitleString("Default Title");
- $this->HandleContent();
- This is kind of messy and needs to be mapped out and possibly redesigned.
- The application will typically implement this as something like:
- $this->PreSkinBuild();
- $this->Skin()->Build();
- // tell the skin to fill in its pieces
- $this->PostSkinBuild();
- $this->Skin()->DoPage();
Admin Pages
"Admin" pages are pages that are more tool-oriented than content-oriented – that is, they tend to have a lot of "action links" (links that do something or change what aspect of the underlying data is being displayed) and tend to be data-oriented rather than text-content-oriented.
Ferreteria provides a set of classes for displaying action links and detecting the page's intended state.
Action links can either be displayed standalone or as part of a header component. There are currently two types of header component: the page header and section headers.
To use either of the header components, you first need to create an array of the action link objects you want to use. For example: <php> $arActs = array( new clsActionLink_option(array(), // an "edit" link 'edit', // link key (value) 'do', // group key (name) NULL, // display when off NULL, // display when on 'edit this supplier' // description (shows as hover-over text) ), new clsAction_section('Manage'), // a static subsection -- just shows the text new clsActionLink_option(array(), // link shows "departments" 'dept', 'show', 'departments', NULL, $strName.' departments' ), new clsActionLink_option(array(), // link shows "catalogs" 'cat', 'show', 'catalogs', NULL, $strName.' wholesale catalogs' )
);
</php>
Once you've created the link array, you can either feed it to the page's title header: <php>$this->Engine()->App()->Page()->PageHeaderWidgets($arActs);</php>
...or you can create a section header, and show it there: <php>$out .= $this->Engine()->App()->Page()->ActionHeader('Section Title',$arActs);</php>