Bookmarked 150 times

SBM 2.5 Aug 2013 - 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.
Since SBM 2.5 you can use Cookies too.
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.

New since May 2012 - fully AJAX driven for comfortable bookmarking

Features

  • Easy to include and setup
  • Works with your authentication and user identifications
  • Cookie, IP-Address, Email-Adress or any other string can be used to identofy your users
  • Can use your existing DB connection or it's own DB connection
  • Just one click to bookmark if authenticated
  • Manage bookmarks if authenticated
  • Add bookmarks AJAX driven
  • Remove bookmarks AJAX driven
  • ...

New since V2.5 August 1st 2013

  • Works with JQuery 1.10.2 and with Jquery 1.4.2 too
  • added COOKIE Support

New since V2.0 2012-05-11

  • AJAX Support
  • works furthermore without javascript too
  • Adding bookmarks without page loading form the form or the link-version
  • Possibility to remove bookmarks without page loading
  • Added a jump-to-bookmark function (select options)

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 With an user id (var $uid) and an variable that indicates that the user is authenticated

$sbm = new SimpleBM($uid,$auth);

Filled in the values of $uid (15) and authenticated status (1)

$sbm = new SimpleBM(15,1);

Just the IP Address ass key, there's no need to authenticatem so set it to 1

$sbm = new SimpleBM($_SERVER["REMOTE_ADDR"],1);

Cookie based, if you use COOKIE in uppercase a cookie will be set (usefull on rotating IPs), there's no need to authenticatem so set it to 1

$sbm = new SimpleBM("COOKIE",1);

Other Examples

$sbm = new SimpleBM($email,$auth);
$sbm = new SimpleBM($user->email,$auth);
$sbm = new SimpleBM($user->id,$user->auth);

ATTENTION

If you like to use the cookie identification you have to include and call initiate the SBM-Class before any other outputs are made

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
and if you like to use cookies, you've to use "COOKIE" as key in uppercase
$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

Add Ajax Functionality

Add javascript files on every page to the header where you want to use the SBM functions
i.e. <head>
...
<script type="text/javascript" src="bm/jquery.1.10.2.min.js"></script>
<script type="text/javascript" src="bm/sbm.min.js" id="sbmjs"></script>
...
</head> ?>
There's no need to include the jquery-file if it's already included.
But it's essential to include the sbm.min.js after the jquery including.
Please make sure, that the sbm.ajax.php, the sbm.min.js and the sbm.class.php are stored in the same directory. The path will be parsed automatically in the sbm javascript file (PHPscriptUrl) and therefore the id sbmjs is added to the script tag.
An uncompressed version is attached to the installation files too.

If you have any special authentication or database settings please add them to the sbm.ajax.php too.

Everything should work out of the box :)

Add Bookmarks with Ajax - Info

Either by clicking the link with the ID bmf or by submitting the form with the ID bmf
Take a look to the example files

Increase number of bookmarks after adding

The value of the bookmarks will be increased by 1 after bookmarking. The number should be placed in an span with the classname sbmcount
Take a look to the example files

Removing Bookmarks with Ajax - Info

Bookmarks can be removed by clicking the removing link with the class rmbm. The parent div disapears after removing.

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

Show Bookmarks Dropdown new since V2.0

To show your users their bookmarks in a dropdown and let them jump to the bookmarks you can use <?php echo $sbm->bookmarksDropdown(); ?>