Skip to content

Plug-in for Frog CMS to add metadata to the pages

License

Notifications You must be signed in to change notification settings

blondak/wolf_page_metadata

Repository files navigation

About

This is a simple plug-in for the Frog CMS. It adds the ability to add more metadata to a page object. Metadata is stored as simple keyword-value pairs.

Whenever metadata is required on page level page_metdata allows the user to add more metadata fields as well as 'hidden' metadata that can be used by other plug-ins.

Motivation

For the page part forms plug-in I was searching for a way to store metadata information for a page (in this case the selected page part form). The core Frog 'page' table is very specific with its metadata (e.g. keywords, layout_id, is_protected, etc.). It is not possible to add additional fields without breaking with the core of Frog.

Instead of creating another specific mapping table only for the page part forms plug-in, I created this 'page_metadata' to add any keyword-value pairs (generic metadata) to a page.

As a side effect the metadata can either be created by the user in the edit interface (visible) or by a plug-in with a custom metadata handler (invisible).

Requirements

Install

Activate the jQuery plug-in

Protect your plug-ins. Edit config.php and add the following line:

define('IN_FROG', true);

Download and extract the released zip file (simple)

POSIX based systems:

cd frog/plugins/
curl -O http://cloud.github.com/downloads/them/frog_page_metadata/page_metadata-v1.0.0.zip
unzip page_metadata-v1.0.0.zip

Microsoft Windows:

  1. Download the zip file
  2. Extract the content to 'frog\plugins\' as sub-folder 'page_metadata'

Use git and simple update to further releases (advanced)

cd frog/plugins/
git clone git://github.com/them/frog_page_metadata.git page_metadata

Active the page_metadata plug-in

Usage

The 'visible' part of the plug-in adds another tab to the page view: the 'More Metadata' tab. With this dialogue any metadata (keyword value pairs) can be added to an existing page. If the value left blank, the metadata gets removed, and there is also a delete button.

Attributes at the page object

The metadata is automatically attached as an associative array to the active page ($this in page, layout, or snippet context).

<?php echo $this->page_metadata["Keyword"]; ?>

If other pages where accessed (e.g. to generate a navigation menu) the plug-in does not expand the metadata to this pages. In this case the helper functions from the 'PageMetadata' model classes must be used. Instead of the $page object, the page_id can be used instead of the $page object, too.

/* Returns only the specific value */
PageMetadata::FindOneByPageAndKeyword($page, $keyword);

/* Returns an associative array with all keywords and their values */
PageMetadata::FindAllByPageAsArray($page);

/* Returns the internal representation (active record) of the metadata */
PageMetadata::FindAllByPage($page);

Extensibility and Observers

Because the plug-in was initially generated as a generic plug-in for other plug-ins to store metadata, the plug-in offers an observer mechanism to hook-in functionality (e.g. a custom form for the metadata).

Therefore the observers subscribing the topic 'view_page_page_metadata' will be called in the view with all metadata objects as parameter.

Observer::notify('view_page_page_metadata', $metadata);

Visibility

If the metadata has the 'visibility' of '0', the user is not able to alter the metadata directly. This value should be manipulated (e.g. select box) by another plug-in that is using the observer topic.

About

Plug-in for Frog CMS to add metadata to the pages

Resources

License

Stars

Watchers

Forks

Packages

No packages published