WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Code Snippet: Search Bookmarks
  • Print
Pages: [1]   Go Down

Author Topic: Code Snippet: Search Bookmarks  (Read 8218 times)

Craig.Rodway

  • Guest
Code Snippet: Search Bookmarks
« on: April 02, 2005, 12:33:35 AM »
Here is a piece of code to allow searching of bookmarks. It's intended to be added to a code module before the bookmarks module, but could be easily adopted to fit into a template.

Code: [Select]
if( isset( $_GET['search'] ) ) {

  $query_links = $database->query("SELECT title,url,target FROM ".TABLE_PREFIX."mod_bookmarks_links WHERE title LIKE '%".$_GET[search]."%' ORDER BY position ASC");

if( $query_links->numRows() > 0 ) {
  print '<p>Search results for "'.$_GET['search'].'":';
  print '<ul>';
  while($link = $query_links->fetchRow()) {
    print '<li>';
    print '<a href="'.$link['url'].'" target="'.$link['target'].'">';
    print $link['title'];
    print '</a>';
    print '</li>';
  }
  print '</ul>';
} else {
 print '<p>Sorry, no results found for "'.$_GET['search'].'".</p>';
}

} else {

  print '<form method="GET" action="'.$_ENV[PHP_SELF].'" style="margin:0px;">';
  print '<p style="margin-bottom:0px;padding-bottom:0px;">Search bookmarks: ';
  print '<input type="text" name="search" size="30">';
  print '<input type="submit" value=" Search "></p>';
  print '</form>';

}

print '<hr>';  // remove this line to get rid of the visible horizontal rule.


Click here to view the live example version :)
Logged

fienieg

  • Guest
Code Snippet: Search Bookmarks
« Reply #1 on: April 02, 2005, 01:28:34 AM »
Thanks Craig, works good  :D
Logged

Offline Ryan

  • Posts: 2048
  • Gender: Male
    • My Homepage
Code Snippet: Search Bookmarks
« Reply #2 on: April 02, 2005, 03:07:27 AM »
Hmm, one day when I get my act together, the bookmarks module will be searchable through the main search feature - so we won't have to write stuff like this anymore. As for now, your code is great! 8)
Logged
Website Baker Project Founder
https://WebsiteBaker.org

To contact me via email, visit:
www.ryandjurovich.c om

Craig.Rodway

  • Guest
Code Snippet: Search Bookmarks
« Reply #3 on: April 02, 2005, 03:15:39 PM »
I didn't notice the bookmarks weren't searchable until after I'd made that code, I just wanted a way to only search the bookmarks, and have the search box on the same page  :wink:
Logged

Offline Ryan

  • Posts: 2048
  • Gender: Male
    • My Homepage
Code Snippet: Search Bookmarks
« Reply #4 on: April 07, 2005, 04:12:19 AM »
Well, great work then! 8)
Logged
Website Baker Project Founder
https://WebsiteBaker.org

To contact me via email, visit:
www.ryandjurovich.c om

Offline bupaje

  • Posts: 592
Re: Code Snippet: Search Bookmarks
« Reply #5 on: August 21, 2010, 08:25:59 PM »
Is there a simple mod to this code to allow it to also search by the text in the title attribute - not only the link text? (This info is currently pulled from the Display field in the Bookmarks module.)

<a href="http://www.example.com/" target="_blank" title="Nice collection of PS brushes with a nifty live preview.">Example</a>
« Last Edit: August 24, 2010, 10:47:23 AM by Argos »
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Code Snippet: Search Bookmarks
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2