Ferreteria/v2/usage/browser

From Woozle Writes Code
< Ferreteria‎ | v2‎ | usage
Revision as of 13:54, 4 March 2017 by htyp>Woozle (status messages)
Jump to navigation Jump to search

How to generate browser output depends on what kind of output you want to generate.

Page Content

<php>fcApp::Me()->AddContentString('your content here');</php>

Note that page content will be preserved in the event of an internal redirect, and should be displayed automatically by the target page.

Status Messages

To indicate the status of an attempted operation, use one of the following: <php>fcApp::Me()->GetPageObject()->AddErrorMessage($s); fcApp::Me()->GetPageObject()->AddWarningMessage($s); fcApp::Me()->GetPageObject()->AddSuccessMessage($s)</php> ...where $s is the message you want to display.

Page Title

There are actually two kinds of page title:

  • browser title: what the browser shows in its window frame
  • content title: text displayed in a standard prominent format at the top of the page, sometimes with a menu

It's usually best to set them both to essentially the same thing, which can be done like this:<php>fcApp::Me()->GetPageObject()->SetPageTitle('Your Title');</php>

To set just the browser title:<php>fcApp::Me()->GetPageObject()->SetBrowserTitle('Your Title');</php>

To set just the content title:<php>fcApp::Me()->GetPageObject()->SetContentTitle('Your Title');</php>

Ferreteria can be configured (via your site's fcPage_standard descendant) to automatically insert your site's name or other text in the browser title (as an indicator that these pages are on your site) while leaving the content title exactly as requested.

We have found that it's better to show the set title (the string you request for the title, which should describe the specific page you're displaying) before the site name, because tabs can be displayed in such a way that only the first part of the title text is visible, and the site name can easily take up all of the available space, leaving no way to distinguish between pages at a glance. A better way to indicate site ownership of tabs is to have a distinctive favicon, though there's no harm in also having your site name after the page descriptor.

Section Headers

Section headers are created from scratch:<php>$oHdr = new fcSectionHeader('Your Section Title',$oMenu);</php>

The $oMenu parameter is optional. The Section Header object must be rendered in order to show up on the page:<php>fcApp::Me()->AddContentString($oHdr->Render());</php>

Header Menus

The content header (which includes the content title) has its own menu object, which you retrieve like this:<php>$oMenu = fcApp::Me()->GetHeaderMenu();</php>

To add a menu to a section header, just create a new menu object (from scratch) before you create the section header object: <php>$oMenu = new fcHeaderMenu(); $oHdr = new fcSectionHeader('Your Section Title',$oMenu);</php>

In either case, you can then add items to the $oMenu object, which will be rendered when $oHdr is rendered.