[Code] Make it easy for people to bookmark your site.

Started by Niteblade, September 19, 2007, 09:48:09 PM

Previous topic - Next topic

Niteblade

Backup your files first!

Here's some Javascript. Be sure to add it after the <body> tag inside index.template.php. (When code is placed outside of the <body> tag, it has a tendency to screw up the rendering of the captcha on registration.)


echo ' <script type="text/javascript">
function addBookmark(title,url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}
</script>';


Next, place the code for the text someplace in your forum. Perhaps under the search bar? I'll include more code than what is needed in order for you get some reference inside index.template.php.


// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td width="90%" class="titlebg2">
<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>
</td>';
echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top">
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0 1ex;" alt="" /></a>
<input type="text" name="search" value="" style="width: 190px;" />&nbsp;
<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
<input type="hidden" name="advanced" value="0" />
<br />
<a title="', $context['page_title'], '" href="#"onmousedown="addBookmark(&#39;', $context['page_title'], '&#39;,&#39;http://www.midessa.net/forum/&#39;)">Bookmark this page</a>';

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';


The actual code would be

<a title="', $context['page_title'], '" href="#"onmousedown="addBookmark(&#39;', $context['page_title'], '&#39;,&#39;http://www.midessa.net/forum/&#39;)">Bookmark this page</a>';


Make sure that you change it to reflect the url of your forum, mmmkay?

Essentially, what this will do is that it will automatically title bookmarks according to the page title. So if someone is browsing a topic about lemmings (Subject: Lemmings RULE!), then the bookmark will be automatically imported as Lemmings RULE!

Experiment and have fun.

affiliate blog

Niteblade

Oh, and since I don't know much about coding (I just know how to play around with the codes that other more intelligent people provide, I won't be able to support this in depth.)
affiliate blog

Advertisement: