GSPageData is a plugin that provides some template tags (functions) to display (or return) other GetSimple pages' data (title, content, etc.)
Download GSPageData version 0.2 (beta)
Installation:
Unzip file and upload contents (gspagedata.php) to your GetSimple site's plugins folder.
Usage:
You can use tags in your template.php file, GetSimple components, your theme's functions.php file...
First select a page by its slug (identifier):
<?php set_gspage('slug'); ?>
Display that page data by using these functions (or template tags):
<?php gspage_title(); ?>
<?php gspage_url(); ?>
<?php gspage_content(); ?>
<?php gspage_excerpt(); ?>
<?php gspage_field('fieldname'); ?>
Notes:
gspage_excerpt() echoes a maximum of 200 characters, unless a different number given as a parameter, e.g. <?php gspage_excerpt(120); ?>
<?php gspage_field('parent') ?>
Examples:
- For one page:
<?php set_gspage('pageslug'); ?>
<b><a href="<?php gspage_url(); ?>"><?php gspage_title(); ?></a></b><br />
<?php gspage_excerpt(256); ?>
- For several pages (using an array of slugs):
<?php foreach(array('slug1','slug2','slug3') as $gspage): ?>
<?php set_gspage($gspage); ?>
<b><a href="<?php gspage_url(); ?>"><?php gspage_title(); ?></a></b>
<p>
<?php gspage_excerpt(150); ?>
</p>
<?php endforeach; ?>
Advanced usage (parameters and returning values):
- You can get a field's value without displaying it by passing a FALSE (or 0) parameter to a tag. Examples:
$myTitle = gspage_title(0);
$myTitle = gspage_title(false); // same as previous one
$WebPage = gspage_url(false);
$myExcerpt = gspage_excerpt(200,false);
$myCustomField = gspage_field('customfield',0);
- function set_gspage('slug') returns FALSE if the page with id 'slug' does not exist, so you can use that to check it before displaying:
<?php if (set_gspage('slug')):?>
...
<?php endif; ?>
Notes:
- I will probably rename this plugin to "GSpages"
- New functions will be added, and some of the current may change (name, parameters...)
- Here's a draft TO-DO list