Article

Accessible Flash Parts 1 And 2

Page: 1 2 3 4 5 6 Next

Concept 5: Deploying Content Based on the User Agent

There are now two important pieces of information in the script environment:

  1. a valid identifier for content in the database table ($go), and

  2. whether the Website visitor is a bot ($bot == true) or not/unknown ($bot is not set in the script environment, i.e. 'false').

It's now time to branch the script depending on the visitor type, and source the requested content.

<?  
/** --- filtering.inc.php  
- display text based content if a bot is found  
- ignore if not.  
**/  
//$bot is set in botcheck.inc.php  
if($bot)  
{  
//show searchbot friendly HTML content according to what    
was decided in getparse.inc.php  
 
   $getBotFriendly_sql = "SELECT header, content, id FROM sitecontent    
WHERE id=$go";  
   //run the query  
   $getBotFriendly_result=@mysql_query($getBotFriendly_sql);  
 
   //set some results  
   $content_header = @mysql_result($getBotFriendly_result,    
0, 'header');  
   $content = @mysql_result($getBotFriendly_result,    
0, 'content');  
 
   //get all the headers and id's for links that the search    
bot can follow.  
   $getAllHeaders_sql = "SELECT id, header FROM sitecontent";  
   $getAllHeaders_result=@mysql_query($getAllHeaders_sql);  
 
?>  
 <div id="vert">  
   <div id="header">  
   <b>From little things, big things grow :</b>  
   <br />  
   providing real-time Flash content for search engines &    
bookmarking Flash Websites  
   - <b><?echo $content_header?></b>  
   </div>  
 
   <div id="content">  
   <h4><?echo $content_header?></h4>  
   <?  
   //convert newlines (\n or \r or \c) in the content to <br />  
   echo nl2br($content);  
   ?>  
   <h4>site navigation headers from the database table...</h4>  
   <?  
   //show the links to other current content available for archiving  
   //the search bot will follow these links.  
   while($header_row = @mysql_fetch_array($getAllHeaders_result))  
   {  
      if($header_row['id'] != -1)  
      {  
      echo "» <a href=\"$abspath?go=$header_row[id]\"    
title=\"more on : $header_row[header]\">";  
      echo "$header_row[header]</a>\n<br />\n";  
      }  
   }  
?>  
  </div>  
 
  <div id="footer">  
     
  </div>  
 
 </div>  
<?  
//include the html footer (</body></html>)  
include("htmlfoot.inc.php");  
// exit from the script so that the flash content is not    
displayed to the bot.  
exit;  
}  
?>

Linking it All Together - Passing the Content Identifier into Flash

Finally, I need to set up a layout for the index.php file that will hold the above three inclusions, and pass the value of $go into the Flash movie. To accomplish this, we append the value to the end of the Flash filename.

<?  
/** ------- index.php ---------- **/  
 
/** ----------- start includes ----------**/  
//connect to mysql server and select the database  
include("database.inc.php");  
 
//parses the variables passed from the URL  
// and checks go against the database  
include("getparse.inc.php");  
 
//include the html head content <html><head><title> etc  
//also a <link .. /> to the stylesheet, meta tags  
//and usage of the $title_add variable  
include("htmlhead.inc.php");  
 
//check to see if the user agent is a bot.  
include("botcheck.inc.php");  
 
//provide plain text content if the user agent is a bot.  
include("filtering.inc.php");  
/** ---------  end includes -----------**/  
 
//deploy the flash content for the humans among us  
//note the go variable is being passed into the flash movie,  
//available as _root.go.  
//This is the key to successful bookmarking of Flash movies.  
?>  
 <div id="wrapper">  
 <!-- XHTML1.0 compliant code to deploy flash movie -->  
 <!-- if you are seeing a textarea-like box  
 you have a corrupt Flash Player ActiveX control.  
 Try uninstalling Flash Player then installing the    
latest and greatest -->  
 
 <object  
  data="<?echo $abspath?>index.swf?go=<?echo $go?>"  
  type="application/x-shockwave-flash" codebase="http://download.  
macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"  
  width="740"  
  height="420">  
  <param name="movie" value="<?echo $abspath?>index.swf  
?go=<?echo $go?>" />  
  <param name="menu" value="false" />  
  <param name="quality" value="high" />  
  <param name="bgcolor" value="#fefefe" />  
   <a href="http://www.macromedia.com/go/getflashplayer"  
   title="link to the Macromedia Flash Player download page">  
   Get the latest Flash Player from Macromedia  
   </a>  
 </object>  
 </div>  
<?  
//end the html  
include("htmlfoot.inc.php");  
?>

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links