The easiest way to create a new widget is to copy
the morpher.w.php3 file to yourwidget.w.php3
The file name before the .w.php3 will be what
the widget is called.
Once you've done that open it up and edit:
- $widget_title to what you want in the title bar
- $widget_canMove and $widget_canClose, set
them true if you want a the buttons for Move
and Close or false for no buttons.
- Then do your code that produces some text or
HTML and store it into the variable $output.
Then close the file, that's it for making it...
the rest is just making sure it gets loaded.
To make your widget selectable from the add widgets dialog, make a copy of you widget into
the user_widgets directory (the file can be
empty, only that there is a file by that name
is what matters).
Finally, if you want your widget to appear
on the demo page by default when a person goes
to your page you need to alter index.php3
where it goes as follows
$MyWidgets =
array(
// c1
array(
"yourwidget", /* inserts your widget at the top of c1 or column 1 */
"browser",
add the "yourwidget" line shown to $MyWidgets
Logout of the page (so your session is deleted
and reloaded) to test if it works.
Here's a hack I did on the morpher widget as
an example...
<?PHP
// -- Frame setup stuff
$widget_title = "This is my widget and $widget is it's name";
$widget_canMove=true;
$widget_canClose=true;
// -- Widget frame content
$output = "hello world";
$output.= "<br>here is a second line.";
// *** Do not alter anything below this point. ***
// ***********************************************
if (!isset($oldfilestatus))
{
$oldfilestatus = "oldfilestatus was not set";
}
$widget_info = "This cache was created at: ".date("l F dS Y h:i:s A")."\\nUpdated for IP: $REMOTE_ADDR\\nPrevious cache was created: ".$oldfilestatus;
// -- return output to caller in the form a variable named after the widget called
// i.e. calling the widget nasdaq returns widget output in $nasdaq
$$widget = $this->frame_widget($output, $widget_title,$widget_info,$widget_canMove,$widget_canClose);
// -- Clean Up Vars
unset($output); unset($widget_title); unset($widget_info);
unset($widget_canMove); unset($widget_canClose);
// We leave $oldfilestatus for other widgets that may wish to display caching info
?>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I needed to add large amounts of static files to the Widget list, so I added a hack to read the .txt files from specified directory, and it appends that list to the WidgetArray. Then they behave as xxxxx.list files. I can send you the update if you wish....
Alex
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a guideline on how to create a new widget? What files do I need/ what do I need to change?
Alex
Alex,
The easiest way to create a new widget is to copy
the morpher.w.php3 file to yourwidget.w.php3
The file name before the .w.php3 will be what
the widget is called.
Once you've done that open it up and edit:
- $widget_title to what you want in the title bar
- $widget_canMove and $widget_canClose, set
them true if you want a the buttons for Move
and Close or false for no buttons.
- Then do your code that produces some text or
HTML and store it into the variable $output.
Then close the file, that's it for making it...
the rest is just making sure it gets loaded.
To make your widget selectable from the add widgets dialog, make a copy of you widget into
the user_widgets directory (the file can be
empty, only that there is a file by that name
is what matters).
Finally, if you want your widget to appear
on the demo page by default when a person goes
to your page you need to alter index.php3
where it goes as follows
$MyWidgets =
array(
// c1
array(
"yourwidget", /* inserts your widget at the top of c1 or column 1 */
"browser",
add the "yourwidget" line shown to $MyWidgets
Logout of the page (so your session is deleted
and reloaded) to test if it works.
Here's a hack I did on the morpher widget as
an example...
<?PHP
// -- Frame setup stuff
$widget_title = "This is my widget and $widget is it's name";
$widget_canMove=true;
$widget_canClose=true;
// -- Widget frame content
$output = "hello world";
$output.= "<br>here is a second line.";
// *** Do not alter anything below this point. ***
// ***********************************************
if (!isset($oldfilestatus))
{
$oldfilestatus = "oldfilestatus was not set";
}
$widget_info = "This cache was created at: ".date("l F dS Y h:i:s A")."\\nUpdated for IP: $REMOTE_ADDR\\nPrevious cache was created: ".$oldfilestatus;
// -- return output to caller in the form a variable named after the widget called
// i.e. calling the widget nasdaq returns widget output in $nasdaq
$$widget = $this->frame_widget($output, $widget_title,$widget_info,$widget_canMove,$widget_canClose);
// -- Clean Up Vars
unset($output); unset($widget_title); unset($widget_info);
unset($widget_canMove); unset($widget_canClose);
// We leave $oldfilestatus for other widgets that may wish to display caching info
?>
This is really cool. Thanks a lot. It worked!!!
If you make anything cool be sure to let me know.
I'd love to see what other people are doing with
it.
-Ironstorm
Yes, I needed to add large amounts of static files to the Widget list, so I added a hack to read the .txt files from specified directory, and it appends that list to the WidgetArray. Then they behave as xxxxx.list files. I can send you the update if you wish....
Alex
Cool send me the hack, I'll prolly put it in
if it makes it easier to update that list.