Specifications
If you look closely at Figures 29.5 and 29.6, you can see that we are passing some parameters
back to index.php in the command line. In Figure 29.5, the URL looks as follows:
http://webserver/chapter29/index.php?expand=6#6
The script reads this as “Expand the item with postid 6”. The # is just an HTML anchor that
will scroll the page down to the part that has just been expanded.
In the second figure, the URL reads
http://webserver/chapter29/index.php?expand=all
Clicking the Expand button has passed the parameter expand with the value all.
Expanding and Collapsing
Let’s see how it’s done by looking at the index.php script, shown in Listing 29.2.
L
ISTING 29.2 index.php—Script to Create the Article View on the Main Page of the
Application
<?
include (‘include_fns.php’);
session_start();
// check if we have created our session variable
if(!session_is_registered(‘expanded’))
{
$expanded = array();
session_register(‘expanded’);
}
// check if an expand button was pressed
// expand might equal ‘all’ or a postid or not be set
if($expand)
{
if($expand == ‘all’)
expand_all($expanded);
else
$expanded[$expand] = true;
}
// check if a collapse button was pressed
// collapse might equal all or a postid or not be set
if($collapse)
{
if($collapse==”all”)
Building Web Forums
C
HAPTER 29
29
BUILDING WEB
FORUMS
721
35 7842 CH29 3/6/01 3:34 PM Page 721