Subject: glCPO

Posted on: 01/09/2014 01:20pm
By: remy

the Common GeekLog Page Object (glCPO).

As a result of the discussion on the new glPage class, I see a need to make inventory of common (html) snippets which can be promoted to a glCPO. in the wiki you may find that gives a visual intro to wireframes. You'll get the concept.

In the manner laid out, any (hierarchical) structure can be documented in a wireframe using rectangles and so be defined as a glCPO. Some examples:

--a list with header + footer and detail lines
--a menu with main- and submenu's
--a pagination bar
--the login box
--a right- or left-block
--a common snippet like a link (COM_createLink) or a toolTip (COM_getToolTip)

What is interesting on the approach, is that any glCPO could be rendered either by a template, either by a JSON object, either by a javascript function. Take a list as the example. It has a header and footer, maybe a search form, and detail lines. Most of us use ADMIN_createList to render a list by handing over a mySQL result set. The list itself, including pagination, is rendered using a template but could be rendered thru a JSON object that is processed by a javascript on the page. There would be nothing to be changed in the logic of (plugin)code as far it is creating the correct glCPO to handle the desired rendering.

This topic is calling for candidates for a glCPO with a focus on snippets.
A snippet glCPO consists of a few html tags rendered in one or two lines. The snippet contains variables like a template.

PHP Formatted Code

COM_createLink: <a href={url} {attributes}>{content}</a>

PHP Formatted Code

COM_createImage: <img src={url} {attributes} title={hint} alt={hint} {xhtml}>

A more complex one:

PHP Formatted Code

hoverover: <img src={theme}/tooltips/images/tooltip.$_IMAGE_TYPE
            title={hint} alt={hint} id=glTooltipIcon {xhtml}>
template: classic.thtml({hoverover}, {class}, {text}, {title}, {link}, {cursor})

The important requirement is that in any case such a snippet can be embedded in a span or div tag without layout consequences. In other words it will adhere to the css box model. Don't worry about quotes in your examples.

Geeklog - Forum