By beckyjohnson on
Hi all,
I wanted to implement the google news trickler on my site. (http://www.google.com/uds/solutions/newsbar/) I went through their process of generating the code and put the js in my tpl file where i wanted it and it seemed to work. Then a coworker took it off because they said it broke the site. So How do I put the js into my site? I know i have to hook up js files to my .info file but what do I do about the internal js? I mean some of this looks like it needs to be in the tpl file but I don't know what parts.
see here for example:
<!-- ++Begin News Bar Wizard Generated Code++ -->
<!--
// Created with a Google AJAX Search Wizard
// http://code.google.com/apis/ajaxsearch/wizards.html
-->
<!--
// The Following div element will end up holding the actual newsbar.
// You can place this anywhere on your page.
-->
<div id="newsBar-bar">
<span style="color:#676767;font-size:11px;margin:10px;padding:4px;">Loading...</span>
</div>
<!-- Ajax Search Api and Stylesheet
// Note: If you are already using the AJAX Search API, then do not include it
// or its stylesheet again
-->
<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&source=uds-nbw"
type="text/javascript"></script>
<style type="text/css">
@import url("http://www.google.com/uds/css/gsearch.css");
</style>
<!-- News Bar Code and Stylesheet -->
<script type="text/javascript">
window._uds_nbw_donotrepair = true;
</script>
<script src="http://www.google.com/uds/solutions/newsbar/gsnewsbar.js?mode=new"
type="text/javascript"></script>
<style type="text/css">
@import url("http://www.google.com/uds/solutions/newsbar/gsnewsbar.css");
</style>
<script type="text/javascript">
function LoadNewsBar() {
var newsBar;
var options = {
largeResultSet : false,
title : "In the news",
horizontal : true,
autoExecuteList : {
executeList : ["WiMAX", "WiMAX Forum"]
}
}
newsBar = new GSnewsBar(document.getElementById("newsBar-bar"), options);
}
// arrange for this function to be called during body.onload
// event processing
GSearch.setOnLoadCallback(LoadNewsBar);
</script>
<!-- ++End News Bar Wizard Generated Code++ -->
Any input would be great help,
Thanks
Becky
Comments
Create Custom block for it
Hi
First enable the "php filter" module from http://yoursite.com/admin/build/modules
after that
go to http://yoursite.com/admin/build/block/add
copy above js into the block body
** you have to use drupal_add_js() function here in block body ***
http://api.drupal.org/api/function/drupal_add_js/6
select input format as php code and save
enable the block in any region where you want
thanks
Thanks! I did that and it
Thanks! I did that and it worked fine. Would it be better if i took all those js files that it links to and declare them on my .info file as well? or should I copy the js and css files and put them on my server and declare them in my .info file that way?
Thanks!
Becky