Codeasearch.com - Search your code with us Login | Register | Contact us
  Forums > Php > Creating basic widgets using php
benaya
Posted on Jul 10, 2008
Join Date: June 2007
Location: India ( Chennai )
Posts: 90
 
Creating basic widgets using php  

Creating basic widgets using php.

Create 3 files

1) Widgets.php
2) Widgets.html
3) .htaccess


Widgets.php
-----------------------------------------------------------------------------------------------------------------------------

<?
// parameter for display in widgets box

$strBorder = ($_REQUEST["border"]=="") ? "border=0" : "border=".$_REQUEST["border"];
$strBgColor = ($_REQUEST["bgcolor"]=="") ? "" : "bgcolor='".$_REQUEST["bgcolor"]."'";
$strWidth = ($_REQUEST["w"]=="") ? "" : "width='".$_REQUEST["w"]."'";
$strHeight = ($_REQUEST["h"]=="") ? "" : "height='".$_REQUEST["h"]."'";

$strWidgetsString = "<table ".$strBorder." ".$strBgColor." ".$strWidth." ".$strHeight." style='border-collapse:collapse;'>";
$strWidgetsString .= "<tr>";
$strWidgetsString .= "<td>Welcome to my Widgets</td>";
$strWidgetsString .= "</tr>";
$strWidgetsString .= "<tr>";
$strWidgetsString .= "<td><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</td>";
$strWidgetsString .= "</tr>";
$strWidgetsString .= "</table>";

?>

// Create runtime div tag for display widgets and embed php
var oElement = document.createElement("div");
oElement.id = "divDisplay";
oElement.innerHTML = "<?=$strWidgetsString?>";
document.writeln(oElement.innerHTML);

----------------------------------------------------------------------------------------------------------------------------




widgets.html
-----------------------------------------------------------------------------------------------------------------------------

<script language="javascript" src="http://yourdomain.com/widgets/widgets.js"></script>

----------------------------------------------------------------------------------------------------------------------------



.htaccess
-----------------------------------------------------------------------------------------------------------------------------

RewriteEngine On
RewriteRule ^widgets.js$ widgets.php

----------------------------------------------------------------------------------------------------------------------------

 Hot Discussion
Go Tech launches Android tablet for Rs 3,999...
Sony targets retailers with quick sales pitches and rew...
Share and discover new activities with Google Schemer...
Samsung gets 9 mn preorders for Galaxy S3: Report...
Google revamps search engine to think like a person...
 
 Discussion Topics
IT News
Php
Javascript
Technology Updates
Asp.Net
MySql
Ajax
Html
Fedora
Software Testing
Asp
Java
General
Flash
Ruby on Rails