Hoctro's Place - Góc Học Trò

I am now more avtively creating and adding contents to my music blog, please take a look. http://hoctroyoutube2010.blogspot.com/

"Latest Headlines" Widget


Dear Friend,

Google tools are just so amazing and innovative. Two years ago I started on my quest of having an AJAX & JSON library for myself to load feeds, now they have it as an Application Programming Interface (API), and then some.

I'm going to show you how to modify the Google Ajax Feed Widget sample to your blog, with three simple steps:

1. Get the key grom Google:

http://code.google.com/apis/ajaxfeeds/signup.html

2. Next, follow the instructions from this article Hacking Technique: How To Modify and add Widget to the Template, in particular section B.4.

Add this code to the header, right in front of the </head> tag. Remember to replace YOUR-KEY text with the new key.



<script src='http://www.google.com/jsapi/?key=YOUR-KEY' type='text/javascript'/>
<script src='http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js' type='text/javascript'/>

<style type='text/css'>
@import url("http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css");

#feedControl {
margin-top : 20px;
margin-left: auto;
margin-right: auto;
width : 440px;
font-size: 16px;
}
.gfg-title {
color : #612e00;
background-color: #FFF3DB;
}
.gfg-title a {
color : #612e00;
}
.gfg-root {
border: 1px solid #956839;
font-family: "Georgia", sans-serif;

}
</style>
<script type='text/javascript'>
function load() {
var homeUrl = "<data:blog.homepageUrl/>";
var feed = homeUrl + "feeds/posts/default";
new GFdynamicFeedControl(feed, "feedControl",
{numResults : 4});

<h6>Widget by <a href='http://hoctro.blogspot.com/2008/09/google-ajax-feed-widget.html'>Hoctro</a></h6>

}
google.load("feeds", "1");
google.setOnLoadCallback(load);
</script>


3. Create a new "HTML/JavScript" widget, then add this line to the content:




<div id="feedControl">Loading...</div>



You can see the new widget on my blog at the moment, in front of the post area.



To change font, color, etc. modify the CSS styles. I override several the default CSS styles to match those of my blog.



.gfg-title {
color : #612e00;
background-color: #FFF3DB;
}
.gfg-title a {
color : #612e00;
}
.gfg-root {
border: 1px solid #956839;
font-family: "Georgia", sans-serif;

}

Good luck and have a nice day.

Hoctro
9/23/08



Update: 10/5/08

To place more than the default of 4 items, look for this line, at the end of step 2,

new GFdynamicFeedControl(feed, "feedControl",
{numResults : 4});


then modify it to become:

new GFdynamicFeedControl(feed, "feedControl",
{numResults : 25});


The maximum value you can put in is 25.
Labels: Archived, Widgets

10 comments:

Harian said...

Wow.. thanks a lot. It's amazing widget

9/10/08 06:45
Is said...

Hoctro, welcome back after the long break :) How's your son doing? Hope all in good health. I'd say I'm an avid reader of your blog.

A comparison between WordPress and Blogger, they do have featured articles with tabs. If you go down below/underneath the container, you'll see small portions of their normal posts/articles.

My question is:-

Can you come out with the hack on the above matter as if I want to have my featured articles displayed, I've to place it manually i.e wrap the content between two divs and call AJAX to fetch the content which is quite tedious. It would be a great help if I simply can choose/select from my posts/articles.

Thanks.

Is

9/10/08 12:54
Hoctro said...

is:

There is kind of difficult the way you want it, since none of the widget has the ability to come up posts as a table to choose from. I'd think the best way is to weight them into priorities for showing, either as labels #5 to #1, or use the latest "Rate this article" from "Blogger In Draft" to show. I'm already thought of such widget, but it's kind of time-consuming to write, then test such lengthy widget. We'll see.

cheers,

hoctro

11/10/08 22:07
proAMATEUR said...

Thank you very much. This is 1 widget great, but if you apply the identical instructions of your blog, it will be my very bad so I customized by inserting the code directly into the template and the result is very much better.
You can visit the http://blogvietshow.blogspot.com to further consultation on this issue agree.

1/11/08 09:32
ေမာင္လူေအး said...

Thanks a lot. It's very good widget!

15/11/08 20:00
donya kewarasan said...

nice and wonderfull, now i love my blog...thank you Hoctro

5/12/08 15:08
suryaden said...

i really like this widget...thanks

6/12/08 09:48
donya kewarasan said...

why it cannot run in google chrome?

11/12/08 12:23
BIZZNURSE said...

Hi Hoctro..! i really admire your tricks! This one really works ! (all of them works) I just love to drop by and try ur tricks!

21/3/10 03:54
yahaya said...

thanks

31/5/10 04:30

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2011 (2)
    • ►  September (1)
      • It's been ten years already! 9.11.2001-9.11.2011
    • ►  January (1)
      • YouTube is now integrated into Blogger!!! (But I s...
  • ►  2010 (8)
    • ►  December (1)
      • Happy New Year 2011 & Introducing my new blog
    • ►  August (5)
      • Dissecting the New Related Articles Widget - Part ...
      • The new comment managing system from Blogger
      • Pages-Related Articles-Your Own Photo: A Blogger's...
      • Introducing The New Related Articles Widget
      • Calling for New Ideas for an Advanced Related Post...
    • ►  March (1)
      • How to quickly upload your pictures to a new or ex...
    • ►  February (1)
      • Embedding Youtube music links in your blog (withou...
  • ►  2009 (5)
    • ►  December (4)
      • Improved "Table of Contents" Widget
      • New and Improved "Related Articles" Widget using t...
      • Translation Widget: Translating your current post ...
      • Season's Greetings
    • ►  October (1)
      • Lenka
  • ▼  2008 (5)
    • ►  October (2)
      • New Translation Widget
      • "Blog List" Widget
    • ▼  September (3)
      • "Latest Headlines" Widget
      • (Superseded) "Related Articles" Widget
      • Gadget
  • ►  2007 (11)
    • ►  September (1)
      • Adding a front page to your blog
    • ►  May (7)
      • Andreas02 Template
      • Yet another TabView Application: Latest Posts of F...
      • TabView Application: A Blogger Hack Directory
      • Introducing TabView Widget - Part 2
      • TabView Widget
      • Overcoming the "25 Latest Posts" Limitation
      • Overcoming the "25 Recent Comments" Limitation
    • ►  February (1)
      • What is a widget, after all? (continued.)
    • ►  January (2)
      • What is a widget, after all?
      • Showing Related Articles to your Post
  • ►  2006 (16)
    • ►  December (2)
      • Showing Headlines by Labels
      • Adding Google Text Search Utility with Custom Tab ...
    • ►  November (2)
      • "Listing of Contents" Widget
      • How To Modify the Blogger Template - The Core Java...
    • ►  October (3)
      • Showing Link List or Label Widgets as Tabs
      • It's a boy!
      • Understanding the New Blogger Template (3)
    • ►  September (9)
      • Understanding the New Blogger Template (2)
      • My Blog Has Just Made It to "Blogs Of Note"!
      • Understanding the New Blogger Template (1)
      • Showing your Blogger Labels as Vertical Tabs
      • Adding a Breadcrumb Trail to your Blogger Post
      • Showing your Blogger Labels as Tabs
      • Blogger Hack: Creating Thumbnail Pictures
      • My First Blogger Template Attempt
      • Welcome to my Blog

Labels

Archived (28) Widgets (10) Miscellaneous (8) Related Articles (4) Blogger Tools (2) Gadgets (1) JavaScript (1) New Music Blog (1) Template Designer (1)
Powered by Blogger.
Loading...