Bookmarked 26 times

SBM 1.1 - How it works

Short intro

You can use any existing user management. Either your userids (integer) or any string key can be used to identify your users. You should also tell the class if your user is authenticated or not. On this demo page I set the auth-value automatically to true and used your IP addresses as key to identify you.
Just include SBM script on every page where you like to offer bookmark function, initialize class and show form or bookmarks.

Features

  • Easy to include and setup
  • Works with your authentication and user identifications
  • Can use your existing DB connection or it's own DB connection
  • Just one click to bookmark if authenticated
  • Manage bookmarks if authenticated
  • ...

New since V1.1 2010-02-12

  • Small fixes in the manual and helpfile
  • Possibility to get an overview of all bookmarks of all users
  • Function to display how many a single page is bookmarked
  • Added possibility to use a link for bookmarking instead of the form

Include file and initialize Class

Include sbm.class.php and initialize Class on every page where you want to use the SBM functions
i.e. <?php include("classes/sbm.class.php");
new SimpleBM($uid,$auth,$db); ?>
More examples of initialization $sbm = new SimpleBM($uid,$auth);
$sbm = new SimpleBM(15,1);
$sbm = new SimpleBM($_SERVER["REMOTE_ADDR"]);
$sbm = new SimpleBM($email,$auth);

The Parameters

$uid
To identify the single users you should provide any key
this could be an ID (integer) you're already using in your user management
or a string, for example an email-address or anything else
$auth
Indicates that the user is authenticated or not
true -> the user is authenticated to your management
false -> the user is NOT authenticated to your management
$db
optional To forward an existing database connection to use within the class or set it to false and define db-settings in sbm.class.php to create db connection within the class

Show Form

The form-button (place where you can set bookmark, or show, that you already bookmarked actual page)
Syntax <?php echo $sbm->showform($title); ?> Examples echo $sbm->showform();
echo $sbm->showform("Simple Bookmark System");

The Parameters

$title
optional The title for your bookmark,
if not set Javascript tries to set current Pagetitle, if this doesn't work, the title will be generated from the URL to bookmark

Show Link new since V1.1

Examples can be fond in the demo under Style Demo and Support
Additional to the formular now bookmarking with help of a simple link is possible - (place where you can set bookmark, or show, that you already bookmarked actual page)
Syntax <?php echo $sbm->showlink($title); ?> Examples echo $sbm->showlink();
echo $sbm->showlink("Simple Bookmark System");

The Parameters

$title
optional The title for your bookmark,
if not set Javascript tries to set current Pagetitle, if this doesn't work, the title will be generated from the URL to bookmark

Show/Manage Bookmarks for Users

To show your users their bookmarks and let them manage their you can call stored bookmarks i.e. with <?php echo $sbm->bookmarks(); ?> or <?php $arr = $sbm->bookmarks(true); ?> The syntax $sbm->bookmarks($array);

The Parameters

$array
true/false - indicates if a HTML formated string should return or an array to format it by yourself
More info can be found here if you have bookmarks saved
The multi dimensional array contains id, title, url and created and you can do whatever you what with this array :)
To generate a link to delete bookmarks you have to use bm_action and bm_id, i.e. <a href='?bm_action=rm&bm_id=15'>remove</a>

Show Bookmarks Overview new since V1.1

you get an overview of all stored bookmarks of all users with <?php echo $sbm->BookmarkStats(); ?> or <?php $arr = $sbm->BookmarkStats(true); ?> The syntax $sbm->BookmarkStats($array);

The Parameters

$array
true/false - indicates if a HTML formated string should return or an array to format it by yourself
More info can be found here if you some bookmarks saved
The multi dimensional array contains number of bookmarks, title and url and you can do whatever you what with this array :)

Count how often Single Page is bookmarked new since V1.1

Examples can be fond on almost every page in this demo.
You get the number of bookmark of single urls with <?php echo $sbm->CountBM(); ?> or <?php
echo $sbm->CountBM("http://yoursite.tld/yourpath/yourfile.php");
?>
The syntax $sbm->countBM($url);

The Parameters

$url
optional - if not set, the current url (where you call the function) will be used