php - page flow issue...
am 14.03.2010 16:53:45 von bruce
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...
===============================================
--need to figure out a way to have the user invoke an action on the
top section of
a page, and have that action, trigger an action on a separate part of the page
example:
i have a page that looks something like this:
+----------------------------------------------------------- ----+
initial navbar stuff (always shown on the page)
+----------------------------------+
+----------------------------------+
(page1)
+----------------------------------------------------------- ----+
i need to have a way to have the user select a "state" from the
statelist, and to then have the tbl/section of the site under
the "cat" form, generated, based on the selected state.
at the same time, i need a way to have the user select an item
from the "dog" tbl, and to have the user select the
cancelBTN/submitBTN, with the app then generating the
subsequent action/logic. the page below, is a kind of
example of what i'm thinking of...
+----------------------------------------------------------- ----+
initial navbar stuff (always shown on the page)
+----------------------------------+
+----------------------------------+
(page2)
+----------------------------------------------------------- ----+
i can see a couple of ways of accomplishing this...
1) i can have a page of logic, that is composed of a bunch of
logic, that is basically an "if block", that generates/displays
the different parts of the page, based on the user actions of
the preceding pages/sections (the cancel/submitBTNs). this approach
would essentially require the entire page to be regenerated with
each BTN selection.
the logic would generate/invoke the correct page elements based
on the user selection/action of the previous page/section.
2) i could possibly utilize div/frames, to allow the content in
the targeted div/frame to be updated/redrawn/regenerated based
on the user action/selection of the previous page/section...
this might be able to be done (not familiar with the
underlying processes to know if this is doable/suitable)
or even a goof approach..
would this apaproach still require the entire page to be
redrawn? or just the portion that's in the targeted
div/frame...
3) somehow invoke javascript/ajax function/features/logic,
to allow the actions/interaction to occur, such that the
content in the targeted div/frame is modified, without
requiring the rest of the page to be modified...
i have no idea if this is doable, or what this would mean,
or involve, or how to apprach this..
or, there might be a different way of accomplishing this
that i haven't even thought of...
any example sites/docs/code would be greatly appreciated...
heck, i'd even be glad to see an actual site/code that
demonstrates how this can/might/should be implemented!!!
thoughts/comments...
thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: php - page flow issue...
am 14.03.2010 20:02:11 von Rene Veerman
sounds like you want to build an ajax site with global config settings
per subpart(=3Dfunctionality) 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'] =3D 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 =3D 'insert into config (userID,config) values
("'.antiSQLinjection($userID).'",
"'.antiSQLinjection(json_encode($SESSION['config'])).'");';
$q=3D$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 setti=
ngs".
$_SESSION['config'] =3D array (
'subparts' =3D> array (
'subPart1Name' =3D> array (
'global' =3D> array ( /* all browser-specific variables for
subPart1Name, "global" level */ ),
)),
'instances' =3D> array (
'subPart1Name_instance1-ID' =3D> array ( /* all overridden settings
for subPart1Name used in subPart1InstanceID */)
),
'currentSiteLayout' =3D> array(
'topLevel' =3D> array (
'subPart1Name_instance1-ID' =3D> array(),
'subPart5Name_instance2-ID' =3D> array(
'children' =3D> array (
'subPart8Name_instance1-ID' =3D> 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 =3D 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=3DsubPartName&config=3D{array_as_j son_urlencoded}
obviously this will include only the relevant $subpartIncludeFile =3D
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 hand=
ling.
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...
>
> ==================== =====
==================== ===3D
>
> --need to figure out a way to have the user invoke an action on the
> top section of
> =A0a page, and have that action, trigger an action on a separate part of =
the page
>
>
> example:
>
> i have a page that looks something like this:
>
> =A0+-------------------------------------------------------- -------+
>
> =A0 =A0 initial navbar stuff (always shown on the page)
>
> =A0 =A0
>
>
> =A0 =A0 +----------------------------------+
> =A0 =A0 =A0
>
> =A0 =A0 +----------------------------------+
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(page1)
> =A0+-------------------------------------------------------- -------+
>
> i need to have a way to have the user select a "state" from the
> =A0statelist, and to then have the tbl/section of the site under
> =A0the "cat" form, generated, based on the selected state.
>
> at the same time, i need a way to have the user select an item
> =A0from the "dog" tbl, and to have the user select the
> =A0cancelBTN/submitBTN, with the app then generating the
> =A0subsequent action/logic. the page below, is a kind of
> =A0example of what i'm thinking of...
>
> =A0+-------------------------------------------------------- -------+
>
> =A0 =A0 initial navbar stuff (always shown on the page)
>
> =A0 =A0
>
>
> =A0 =A0 +----------------------------------+
> =A0 =A0 =A0
>
> =A0 =A0 +----------------------------------+
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(page2)
> =A0+-------------------------------------------------------- -------+
>
>
> i can see a couple of ways of accomplishing this...
>
> 1) i can have a page of logic, that is composed of a bunch of
> =A0logic, that is basically an "if block", that generates/displays
> =A0the different parts of the page, based on the user actions of
> =A0the preceding pages/sections (the cancel/submitBTNs). this approach
> =A0would essentially require the entire page to be regenerated with
> =A0each BTN selection.
>
> =A0the logic would generate/invoke the correct page elements based
> =A0on the user selection/action of the previous page/section.
>
> 2) i could possibly utilize div/frames, to allow the content in
> =A0the targeted div/frame to be updated/redrawn/regenerated based
> =A0on the user action/selection of the previous page/section...
>
> =A0this might be able to be done (not familiar with the
> =A0underlying processes to know if this is doable/suitable)
> =A0or even a goof approach..
>
> =A0would this apaproach still require the entire page to be
> =A0redrawn? or just the portion that's in the targeted
> =A0div/frame...
>
> 3) somehow invoke javascript/ajax function/features/logic,
> =A0to allow the actions/interaction to occur, such that the
> =A0content in the targeted div/frame is modified, without
> =A0requiring the rest of the page to be modified...
>
> =A0i have no idea if this is doable, or what this would mean,
> =A0or involve, or how to apprach this..
>
>
> or, there might be a different way of accomplishing this
> =A0that i haven't even thought of...
>
> any example sites/docs/code would be greatly appreciated...
> heck, i'd even be glad to see an actual site/code that
> demonstrates how this can/might/should be implemented!!!
>
>
> thoughts/comments...
>
> thanks
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php