"Bookmark us" on your vBulletin forum!

Discussion in 'Member Articles & Tutorials' started by Michael, Nov 23, 2009.

  1. Michael

    Michael Regular Member

    Joined:
    Jan 18, 2004
    Messages:
    166
    Likes Received:
    35
    The code within this article is the property of dynamicdrive. This is my short guide on how to add it to a vbulletin forum. This code is meant to work cross browser supporting IE4+, FF1+ and Opera7+.

    A screenshot:

    awww.adminaddict.net_data_MetaMirrorCache_25d382bc9a179825d9e5376fcf59cc70.gif

    Firstly open up your headinclude template and paste this code at the bottom:

    HTML:
    <script type="text/javascript">
    
    /***********************************************
    * Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    /* Modified to support Opera */
    function bookmarksite(title,url){
    if (window.sidebar) // firefox
    window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
    } 
    else if(document.all)// ie
    window.external.AddFavorite(url, title);
    }
    </script>
    Some people may opt for placing the above code within their footer which you may do so if you wish.

    After placing that and saving it you now need to edit your footer. Find this within your footer:

    HTML:
    $vboptions[copyrighttext]
    Now edit accordingly the following code to match your websites address as well as its name:
    HTML:
    <br /><a href="javascript:bookmarksite('Website Name', 'http://www.adminaddict.net')">Bookmark this site!</a>
    If your websites name uses apostrophes remember to add a \ before the apostrophe.

    Once you have that typed up to your liking place it after
    HTML:
    $vboptions[copyrighttext]
    .

    The following code was provided by Webmist which you may use instead of the above for the bookmark link to bookmark specific forums and use the specific forums title:

    HTML:
    <if condition="THIS_SCRIPT == 'index'">
    <br /><a href="javascript:bookmarksite('Your Site Name', 'http://www.yoursite.com/')">Bookmark this site!</a> 
    <else />
    <br /><a href="javascript:bookmarksite('$foruminfo[title]', 'http://www.yourforum.com/forumdisplay.php?f=$foruminfo[forumid]')">$foruminfo[title]</a> 
    </if>
    
    Save the template and you should now have a functioning bookmark us link. If you wish for it to be more prominent I suggest using CSS to style the link by adding a class and some additonal CSS or moving the link code elsewhere within your vb templates to another more prominent location.

    Hope this helps anyone looking to add one of these to their vb forums :)

    This post has been promoted to an article
     
    4 people like this.
  2. Webmist

    Webmist Champion

    Joined:
    Jan 30, 2008
    Messages:
    305
    Likes Received:
    18
    Location:
    US
    First Name:
    Jen
    Great one. I haven't tried it but I believe you can also use conditionals in your href for threads and post.
     
  3. Michael

    Michael Regular Member

    Joined:
    Jan 18, 2004
    Messages:
    166
    Likes Received:
    35
    Neat idea, if you get that to work I will add it up and credit you for it :)
     
  4. Brandon

    Brandon Regular Member

    Joined:
    Jun 1, 2009
    Messages:
    6,602
    Likes Received:
    1,707
    Location:
    Topeka, Kansas
    First Name:
    Brandon
    demo or screenshot please?
     
  5. Michael

    Michael Regular Member

    Joined:
    Jan 18, 2004
    Messages:
    166
    Likes Received:
    35
    I have a screenshot of it in another location, it is just a link :)

    awww.adminaddict.net_data_MetaMirrorCache_8ce6fd89fab1914a32c5e935a523da64.gif

    Edit: Proper screenshot added to first post ;)
     
  6. Webmist

    Webmist Champion

    Joined:
    Jan 30, 2008
    Messages:
    305
    Likes Received:
    18
    Location:
    US
    First Name:
    Jen

    Here's the code to put in the footer. The first is for the index page and the second is for the forum id. Of course you'll have to format your style.

    Code:
    <if condition="THIS_SCRIPT == 'index'">
    <br /><a href="javascript:bookmarksite('Your Site Name', 'http://www.yoursite.com/')">Bookmark this site!</a> 
    <else />
    <br /><a href="javascript:bookmarksite('$foruminfo[title]', 'http://www.yourforum.com/forumdisplay.php?f=$foruminfo[forumid]')">$foruminfo[title]</a> 
    </if>
    
     
  7. Dan

    Dan Future Proof

    Joined:
    Jul 16, 2009
    Messages:
    368
    Likes Received:
    84
    Location:
    Staffordshire
    First Name:
    Dan
    Is there anything you can change the code to so that it will bookmark actual topics too? So perhaps
    Code:
    <if condition="THIS_SCRIPT == 'index'">
    <br /><a href="javascript:bookmarksite('Your Site', 'http://www.yoursite.com/')">Bookmark this site!</a> 
    <else />
    <br />Bookmark this thread/topic: <a href="javascript:bookmarksite('$threadinfo[title]', 'http://www.yoursite.com/showthread.php?t=$threadinfo[threadid]')">$threadinfo[title]</a> 
    </if> 
    would work?

    Edit: I checked and it does. It would be cool if we could get the forum to work with it too but I'm not sure how the if/else would work. Perhaps somebody can do that?
     
  8. Webmist

    Webmist Champion

    Joined:
    Jan 30, 2008
    Messages:
    305
    Likes Received:
    18
    Location:
    US
    First Name:
    Jen
    What do you mean with forums?

    Like:

    Code:
    
    <if condition="THIS_SCRIPT == 'index'">
    <br /><a href="javascript:bookmarksite('Your Site Name', 'http://www.yoursite.com/')">Bookmark this site!</a> 
    <else />
    <if condition="THIS_SCRIPT == 'showthread'">
    <br /><a href="javascript:bookmarksite('$threadinfo[title]', 'http://www.yoursite.com/showthread.php?p=$threadinfo[threadid]')">$threadinfo[title]</a>
    <else />
    <br /><a href="javascript:bookmarksite('$foruminfo[title]', 'http://www.yourforum.com/forumdisplay.php?f=$foruminfo[forumid]')">$foruminfo[title]</a> 
    </if>
    </if> 
    
    
    You can do it with just about anything on the forums. It's just formatting the calls.
     

Share This Page