sounds like you want to build an ajax site with global config settings
per subpart(=functionality) for each browser-client.
if it got it right your other requirements are;
- you have run-time config/state settings per subpart instance that
other subparts' instances need to access.
- you want to be able to load subparts within subparts on the site,
also with varying configs.
so i'd say you need a $_SESSION['config'] = array (array()).
if you need to store your config, put it in a mysql db with
adodb.sf.net, single table, fields: userID (varchar(250)),
sessionStartDate (datetime), [more fields], config (text).
$sql = 'insert into config (userID,config) values
("'.antiSQLinjection($userID).'",
"'.antiSQLinjection(json_encode($SESSION['config'])).'");';
$q=$adoDBconn->execute($sql); if ($q!==false) { echo 'config updated.'
};
don't bother to make a sql datamodel for the config until it's old and
rusted, or you'll waste much time updating it when your app evolves.
anyways, all subparts need a unique name.
and all instances of any subpart also need an (autogenerated via
random-string / start-date-time) ID/name.
an instance is a running copy of a subpart, with it's own $localConfig.
and all variables in a config for a subpart need to get short yet
descriptive, standarized names. without a prefix.
this is to allow "superglobals" to be overriden by "more local config settings".
$_SESSION['config'] = array (
'subparts' => array (
'subPart1Name' => array (
'global' => array ( /* all browser-specific variables for
subPart1Name, "global" level */ ),
)),
'instances' => array (
'subPart1Name_instance1-ID' => array ( /* all overridden settings
for subPart1Name used in subPart1InstanceID */)
),
'currentSiteLayout' => array(
'topLevel' => array (
'subPart1Name_instance1-ID' => array(),
'subPart5Name_instance2-ID' => array(
'children' => array (
'subPart8Name_instance1-ID' => array()
)
)
)
)
);
Because this allows for much flexibility, that also means it can get messy.
Be careful not to put paradoxes in such a config array.
Or sensitive data.
But it does allow for saving all runtime config settings for any
number of apps on a web desktop, with any number of child-apps per
app.
You need a way to load these subparts without loading too much code.
Let's put the "front-end for a subpart" in a script filename &
function-name that can be called polymorphically.
$subpartIncludeFile = HD_ROOT.'php/subpart_'.$subPartName.'.php';
And lets give each such script at least a function named
'loadHTML_subpart_'.$subPartName ($configArray);
This function should return the HTML needed for the subpart given a
possible $configArray, and this function should call CMS-level
functions to query &/ update the $_SESSION['config'] aswell.
And let's make a single script to load a div with a subpart, to be
called from javascript;
/php/loadSubpart.php?name=subPartName&config={array_as_json_urlencoded}
obviously this will include only the relevant $subpartIncludeFile =
HD_ROOT.'php/subpart_'.$subPartName.'.php';
Centralize your CMS/MVC logic in a single (or a few) require_once()
script(s) and require_once() them at the top of index.php (and at the
top of /php/subpart_xyz.php);
/php/myCMSfunctions.php
Your index.php can put out HTML that uses ajax at all times to load
subparts, or it can push all required html for a page out in 1 go.
Afterall, it has access to the (stored) $_SESSION['config'], and can
load and run the subparts like the ajax script /php/loadSubpart.php
would.
The latter is better imo because it saves some overhead.
As for the javascript end, i recommend jquery.com to simplify all ajax handling.
Their docs are quite good too.
You'll at least need to build a javascript function
loadSubpart(divID_string, subpartName_string, configOverride_array).
Best to put all your CMS' js functions in a single js object from the
start, to keep the namespace clean.
For an example of how to set something like that up, have a look at
http://mediabeez.ws/htmlMicroscope-1.3.0/hm.source.js (site may be
offline for hours sometimes, check "htmlmicroscope" via google and use
the googlecode link to get a copy)
If you need the entire config on the js end (security risks!) then use
json_encode to transfer between php and js. JS has no native
json_encode, but there are several good ones for free on json.org
good luck :)
On Sun, Mar 14, 2010 at 5:53 PM, bruce wrote:
> hi.
>
> got a situation for a potential page that i'm playing with. i'm trying
> to figure out how to implement it, and the best/good approach to this.
> i'm actually considering integrating this kind of process within a cms
> (joomla/mambo/cmsms/etc..) but right now, this is in the initia
> thought stage...
>
> if you have a thought/page that i can lok at that's actually
> implementing this kind of flow.. i'd really like to see it..
>
> so, here goes...
>
> ==