Advised to check out ModX CMS
http://www.modxcms.com so you can understand how the following implementation below works.
For the online example (still a WIP) you can log in as a guest administrator at the following URL:
http://glidias.freehostia.com/manager/Username: guest
Password: guest123
The experimental site i'm making is at the root url.
http://glidias.freehostia.com/The site .xml is at
http://glidias.freehostia.com/?id=50 . Obviously, you can simply log into the manager as a guest and peek into the other resources being used to generate the site.
I've set up some simple templates/snippets that allows you to to get your ModX CMS site structure working into Gaia Flash Framework. It's only the beginning though so it isn't much.. but hope you find it useful. With it, you can create your "site.xml" online with ModXCMS, and maintain your content from there. Generally, the design of such an online content-managed Gaia site involves the following:
- You have a standard ModX page template chunk you use for all Gaia Page-based nodes. You can create any number of pages that use this reusable chunk of code below, which is based off Gaia's standard SEO html page template, only I replaced the various portions with various PHP snippet/placeholder calls under ModX, in order to have a fully functioning template. With this chunk, say goodbye to re-scaffolding/managing multiple .html files offline.
{{gaiaSEOTemplate}}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>[(site_name)] | [*pagetitle*]</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<script type="text/javascript" src="assets/js/swfobject.js"></script>
<script type="text/javascript" src="assets/js/swfaddress.js"></script>
<script type="text/javascript">
var flashvars = {
siteXML: "/index.php?id=47",
branch: [!GetGaiaBranch!]
};
var params = {
menu: "false",
scale: "noScale",
allowFullscreen: "true",
allowScriptAccess: "always",
bgcolor: "#ffffff"
};
var attributes = {
id:"CGG"
};
swfobject.embedSWF("assets/flash/main.swf", "altContent", "1024", "813", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
</script>
<style type="text/css">
html, body { height:100%; background-color:#aaaaaa }
body { margin:0 auto; }
</style>
</head>
<body>
<div id="altContent">
<h1>[(site_name)]</h1>
<h2>[*pagetitle*]</h2>
<p>You need Flash player to view this content beautifully.</p>
[[Wayfinder?startId=`0`]]
<div id="copy">
[*content*]
</div>
<p><a href="http://www.adobe.com/go/getflashplayer"><img
src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt="Get Adobe Flash player" /></a></p>
</div>
</body>
</html>
The Site XML
Here's an example online siteXML link what can be generated online. :
And the online link:
http://glidias.freehostia.com/?id=50I'll go through the siteXML specs later. For now, read through the template specs.
Template Specs
Here are the 3 different template specs for the 3 different node types, particularly template variables being used for them.
1) == The page node: ==
Template vars being used:
(You'd need to copy and paste link into URL address bar)
http://glidias.freehostia.com/assets/images/modx/gaiaPageTVs.PNGThis template uses the {{gaiaSEOTemplate}} chunk to display content.
2) == The Index page node: ==
Template vars being used:
(You'd need to copy and paste link into URL address bar)
http://glidias.freehostia.com/assets/images/modx/gaiaIndexPageTVs.PNGThis template uses the {{gaiaSEOTemplate}} chunk to display content.
3) == The asset resource node: ==
Template vars being used:
(You'd need to copy and paste link into URL address bar)
http://glidias.freehostia.com/assets/images/modx/gaiaAssetTVs.PNGAsset nodes' src url normally links directly to the content URL on the Modx site, unless otherwise stated. Be sure to declare the necessary inline attributes (like 'type="xml"') to explicitly declare the type of asset you wish to have under Gaia, since by default, there's no file extensions to indicate the type of asset being used.
By default, the tempate uses the [*content*] placeholder to display content directly.
Here's how different page settings can affect the way child nodes are arranged for the Gaia siteXML.
(You'd need to copy and paste link into URL address bar)
http://glidias.freehostia.com/assets/images/modx/siteXMLnested.PNG[/img]
This allows you to "flatten" your site for Gaia (certain child pages/assets can be brought out as siblings), so the Modx site structure doesn't need to match Gaia's site structure. It even generates a routing "siteXML.route" XMLList table that serves as a useful reference to look up resources by href, id or alias attribute within your Gaia site..
All page ids are set to the unique modx document ids by default, this is because many of such sites may have their pages "flattened" as siblings (1 level deep only) , such that the Gaia site.xml structure does not reflect the content structure in the Modx site. To prevent conflicting ids , I've resorted to using Modx numeric unique ids for each page asset, so that regardless of where it's found in the Gaia site structure, there's no worry as all page ids will be unique anyway. Since the [[GetSiteXML]] snippet generates friendly "route" attributes based off each page node within the Modx site structure, it's a win-win situation, allowing a completley flattened site with unique ids pointing to each page resource, yet having proper the SWF Addresses being shown if "routing" is set to true in [[GetSiteXML]] code. (Otherwise, Gaia will use it's default title-based pretty URL mechanism).
__________________
Last but not least, the source code for the snippets:
[[GetSiteXML]] snippet to scaffold your siteXML dynamically at runtime. This basically echoes out the whole siteXML structure. You need some Modx page to host this snippet obviously. (Also, it's obvious that such a page should use a template containing a template variable of "isGaiaIndexPage" to block itself from being shown in the outputted siteXML code ). Same goes with other pages that host other services that you want to remain hidden from the siteXML output.
Additionally, you need to register page-based templates in the snippet using their template ids in a lookup assosiative array table (as shown in the line: $pageLookupVars["templateIds"] = array(5=>true); ).
This is to indicate that such resources will end up using Gaia's "page" node (template id of "5"), otherwise "asset" is always used by default. For page-based assets, a "seo" attribute is created that points to the respective content URL inside the Modx CMS site. :
[[GetSiteXML]]
<?php
$page= 0;
$pageLookupVars = array('isGaiaIndexPage','gaiaInlineAttributes','gaiaDescendantXML', 'gaiaPageSrc', 'gaiaRoute', 'gaiaSiblingChildren');
$assetLookupVars = array('isGaiaIndexPage','gaiaInlineAttributes','gaiaDescendantXML', 'gaiaAssetId', 'gaiaAssetSrc');
// Setup template ids and starting variables
$pageLookupVars["templateIds"] = array(5=>true);
$assetLookupVars["templateIds"] = array(6=>true);
$basePath = "index"; // index/main
$indexPageId = 47;
function getDocs($modx, $pgVars, $assetVars, $basePath, $startid, $parentBranch, $parentSibling, $routStr, $gaiaPath) {
$docs = $modx->getActiveChildren($startid);
foreach ($docs as $key => $doc) {
$id = $doc['id'];
$data = $modx->getDocument($id);
$isPage = $pgVars["templateIds"][$data['template']];
$nodeName = $isPage ? "page" : "asset";
$lookupvars = $nodeName == "page" ? $pgVars : $assetVars;
$tplvars = $modx->getTemplateVarOutput($lookupvars, $id);
if ($tplvars["isGaiaIndexPage"]) continue;
$isPage = $nodeName == "page";
$branchId = $doc['alias']!='' ? $doc['alias'] : $id;
$siblingChildren = $nodeName == "page" ? $tplvars["gaiaSiblingChildren"] == "parent" ? $parentSibling : $tplvars["gaiaSiblingChildren"] == "true" : false;
$innerXML = $tplvars["gaiaDescendantXML"];
$myInlineAttributes = "";
$parentRoute = $parentBranch == "" ? $branchId : $parentBranch."/".$branchId;
$route = $tplvars["gaiaRoute"] ? $tplvars["gaiaRoute"] : $parentRoute;
$dispid= $tplvars["gaiaAssetId"] ? $tplvars["gaiaAssetId"] : $nodeName=="page" ? $id : $branchId;
$myGaiaPath = $gaiaPath."/".$dispid;
$resourceURL = $modx->makeUrl($id);
$addRout = '<route id="'.$id.'" alias="'.$doc['alias'].'" href="'.$resourceURL.'" path="'.$myGaiaPath.'" />';
$routStr .= $addRout;
$myInlineAttributes.=' id="'.$dispid.'"';
$myInlineAttributes.=' route="'.$route.'"';
$myInlineAttributes.=' title="'.$data["pagetitle"].'"';
$myInlineAttributes.= $data["hidemenu"] ? ' menu="false"' : ' menu="true"';
if ( $nodeName=="page" ) $asrc = $tplvars["gaiaPageSrc"];
else $asrc = $tplvars["gaiaAssetSrc"]!="" ? $tplvars["gaiaAssetSrc"] : $resourceURL;
$myInlineAttributes.= ' src="'.$asrc.'"';
$myInlineAttributes.= $nodeName=="page" ? ' seo="'.$resourceURL.'"' : "";
$myInlineAttributes.= ' '.$tplvars["gaiaInlineAttributes"];
$echoStr = '<'.$nodeName.' '.$myInlineAttributes .' >'.$innerXML;
echo str_replace('&', '&', $echoStr);
if (!$siblingChildren) {
if ( $modx->getActiveChildren($id) ) $routStr = getDocs($modx,$pgVars,$assetVars,$basePath, $id, $parentRoute, $siblingChildren, $routStr, $myGaiaPath);
echo( '</'.$nodeName.'>' );
}
else {
echo( '</'.$nodeName.'>' );
if ( $modx->getActiveChildren($id) ) $routStr = getDocs($modx,$pgVars,$assetVars,$basePath, $id, $parentRoute, $siblingChildren, $routStr, $gaiaPath);
}
}
return $routStr;
}
echo <?xml version="1.0" encoding="utf-8"?>';
echo '<site title="[(site_name)]" indexFirst="true" menu="true" routing="true" preloader="/assets/flash/preload.swf" >';
$indexDoc = $modx->getDocument($indexPageId);
$tplvars = $modx->getTemplateVarOutput($pageLookupVars, $indexPageId);
$myInlineAttributes = "";
$myInlineAttributes.= ' src="'.$tplvars["gaiaPageSrc"].'"';
//$myInlineAttributes.= ' seo="'.$modx->makeUrl($indexPageId).'"';
$myInlineAttributes.= ' '.$tplvars["gaiaInlineAttributes"];
echo '<page id="index" title="CGG Index" '.$myInlineAttributes.'>';
echo $tplvars["gaiaDescendantXML"];
//echo '<page id="main" src="/assets/flash/section.swf">';
$routStr = getDocs($modx, $pageLookupVars, $assetLookupVars, $basePath, 0, "", $tplvars["gaiaSiblingChildren"] == "true", "", $basePath);
//echo '</page>';
echo "</page>";
echo $routStr;
echo "</site>";
?>
[[GetGaiaBranch]] snippet to retrieve Gaia page branch path from current page resource id, to allow Gaia redirection from any Modx page.
<?php
// Setup template ids and starting variables
$basePath = "index";
$lookupvars = array("gaiaSiblingChildren");
$indexPageId = 47;
$id = $modx->documentIdentifier;
$derivedPath = $id;
while ( $parent = $modx->getParent($id,0,'id, template') ) {
$id = $parent["id"];
$derivedPath = $id."/".$derivedPath;
}
$chkArray = explode("/", $derivedPath);
$tplvars = $modx->getTemplateVarOutput($lookupvars, $indexPageId);
$siblingChildren = $tplvars["gaiaSiblingChildren"] == "true";
$derivedPath = "";
$lastParentPath = "";
foreach($chkArray as $str) {
$tplvars = $modx->getTemplateVarOutput($lookupvars, $str);
$siblingChildren = $tplvars["gaiaSiblingChildren"] == "parent" ? $siblingChildren : $tplvars["gaiaSiblingChildren"] == "true";
$derivedPath = $lastParentPath."/".$str;
if (!$siblingChildren) $lastParentPath = $derivedPath;
}
return $basePath."".$derivedPath;
?>
This is used in the {{gaiaSEOTemplate}} chunk to output the appropiate branch path for the Gaia site. Excerpt below:
var flashvars = {
siteXML: "/index.php?id=47",
branch: [!GetGaiaBranch!]
};
Sorry, if this seems like a mouthful. The idea is very simple actually. Hopefully with some examining and tinkering you can figure this out to create your own ModX/Gaia-Powered CMS site!