Plugin: book marks manager
Posted: 16 August 2004 11:49 AM   [ Ignore ]  
Summer Student
Total Posts:  16
Joined  06-16-2004

I wanted to use the “quick links” in my site but I didn’t see an easy way to use those so I made a plugin for members to create/edit/delete bookmarks that show up on my site. I haven’t picked a good DHTML menu system so I don’t have a demo readily available but I figured I post this plugin b/c I’m in need of some assistance on it. From the usage, I have a hack made to the core.input.php. I REALLY would like to do this a different way. If anyone knows please tell me. All I need is a way to pass information via url to this plugin (maybe via something else?).  You can get the plugin here:

book_marks.php


And if anyone knows about the communicate module, please visit my other post regarding email emailing and custom profile fields

Here’s the usage:

NOTE!!!!
———————————-
This script uses a hack to the core.input.php. I didn’t know of any other way to get the information by a link. If anyone knows, let me know. You have to add the follwoing to line 178 of core.input.php. It’s in the parse_uri function and after ‘does uri have session id’.

if(preg_match("/(.+)del_bookmark_id\=(\d+)(.*)/i",$uri, $matches)) {
                $_GET[
'del_bookmark_id'] = $matches[2];
                
$uri = $matches[1] . $matches[3];
            
} else if(preg_match("/(.+)bookmark_id\=(\d+)(.*)/i",$uri, $matches)) {
                $_GET[
'bookmark_id'] = $matches[2];
                
$uri = $matches[1] . $matches[3];
            
}



INSTALL
———————————
You can run the book_marks::install() function to generate the nessessary tables or you can just copy/paste the sql cmds into your choice of sql manager.


USAGE
——————-
I use the function bookmarkmanager to get all the GET information and take any actions. I just place it at the top of the template page. Messages will come from it if you don’t add the parameter msgs=“no”. Use it like this:

{exp:book_marks:bookmarkmanager}
—OR—
{exp:book_marks:bookmarkmanager msgs=“no”}

For editing and adding bookmarks, I use this form:

<form method=“post” action=”{path=to/thistemplate}” name=“bookmark_manager” onreset=“location.href=’{path=to/thistemplate}’”>
<input type=“hidden” name=“bookmark_edit” value=”{exp:book_marks:getinput which=“edit_id”}” />
<p>{exp:book_marks:getinput which=“title”}:<br />
<input type=“text” name=“bookmark_name” size=“40” maxlength=“240” value=”{exp:book_marks:getinput which=“name”}” style=“margin: 3px 3px 3px 10px;” />
<input type=“text” name=“bookmark_url” size=“40” maxlength=“240” value=”{exp:book_marks:getinput which=“url”}” style=“margin: 3px 3px 3px 10px;” /></p>
<input name=“submit” type=“submit” value=”{exp:book_marks:getinput which=“submit”}” style=“margin: 3px 3px 3px 10px;” /> <input type=“reset” value=“cancel” style=“margin: 3px 3px 3px 10px;” />
</p>

And this viewer (contains the edit/delete cmds):

<hr />
<h2>current bookmarks:</h2>
<table border=“0” cellspacing=“4” cellpadding=“0” width=“100%”>
<tr><td><p>name</p></td><td><p>location</p></td><td><p>controls</p></td></tr>
{exp:book_marks}
<tr>
<td><p style=“font-size: 12px;”><a href=”{bookmark_url}”>{bookmark_name}</a></p></td><td><p>{bookmark_url_short}</p></td>
<td valign=“top”><p><a href=”{path=to/thistemplate}{edit_bookmark}”>edit</a> | <a href=”{path=to/thistemplate}{delete_bookmark}” onclick=“javascript:return confirm(‘Are you sure you want to delete this bookmark?’)”>delete</a></p></td>
</tr>
{/exp:book_marks}
</table>
</form>

As you can see, book_marks has these possible values:
{bookmark_name} - The name of the bookmark that was added by the user.
{bookmark_url_short} - A way of truncating the url (incase it’s really long). Edit the php file to change.
{bookmark_url} - The URL of the bookmark.
{edit_bookmark} - An appendage to the URL to edit a bookmark (requires hack, see above!)
{delete_bookmark} - An appendage to the URL to delete a bookmark (requires hack, see above!)

Profile
 
 
Posted: 16 August 2004 06:13 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

You can pass information as segments in the URL and retrieve it in a Template via URL Segments.


What you have doesn’t really sound like a “Plugin”.  Plugins in EE don’t create or use their own database tables; they only access already-existing information.  It sounds more like you need a Module, rather than a Plugin.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 17 August 2004 12:53 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  16
Joined  06-16-2004

Ok, I’ll convert it to a module. But with the URL segments, how can I pass a number, becuase when I was doing index.php/templategroup/template/44 where 44 was a number of one of the bookmarks, it would goto the home page. Should I make some funny script that’ll convert 44 into ‘fourtyfour’?

Profile
 
 
Posted: 17 August 2004 02:22 PM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

Prefix the number with some letter, such as “b44”.  If you simply leave it as a number then EE is going to interpret it as an Entry ID and try to display entry #44.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65102 Total Logged-in Users: 58
Total Topics: 82263 Total Anonymous Users: 27
Total Replies: 442104 Total Guests: 272
Total Posts: 524367    
Members ( View Memberlist )