How to create a Google Powered Site using Coldfusion
Farewell Typewriter's website is the one site I built that is pretty much Google powered. The site also integrates Blogger feeds so that the content owners can utilize already existing tools to publish news & blogs. In addition, I used Picasa to power the photos section, Youtube for the video section, Google Groups for the mailing list, Google Checkout for the merch store, Google Analytics for site statistics, and soon to be Google calendar for show dates.
Here's a snapshot of that site:

Set up is quite easy and it starts out with you opening up a Google account if you havent already. From there, you'll be able to set up everything from your calendar, to your blogs, and your photo albums.
Setting up Google Analytics, Groups, and Checkout is easy. Just follow the simple steps in setting up your account. At the end, all you need is a snippet of code they provide that you can simply copy and paste into your pages.
For YouTube, the easiest way is to create a video playlist and copy and paste the code they provide at the end to embed the YouTube player into your page. Remember to choose the embed code, not the link to the player.
Setting up Blogger is a bit trickier. The key thing is to set up your account to publish to an FTP site. You may find this on your Blogger dashboard under Settings > Publishing.
Once you're in the Publishing settings page, make sure you set view permissions to "Anybody" and also set the default template to "Classic" (you can always change this later). From there simply provide all your host/ftp information. Make sure that if you intend to run any sort of Coldfusion code to change the Blog File Name extension to "cfm". Hit Save Settings, submit, and publish. If all goes well, your blog will soon start publishing to your own server.
To display blog feeds/headlines, first look for the rss.xml feed file usually located in the root directory of your Blog File Path. Once you have that information, use the following code on your page to parse the xml feed so that you'll be able to manipulate it later:
This will let enable you to grab the feed via cfhttp. You can then use, xmlParse to create an rss object and parse the xml feed:
To temporarily view the contents of this object, use:
That will give you a glimpse of the actual contents of the feed in an easy to view structured format. From there, you can easily figure out how to display the right content by traversing through the "branches" using dot notation. You're essentially drilling down to get to your content much like trying to get to a particular file located in a series of subdirectories. For example, to display the title of the first blog on the list, simply output the following:
To display the second one, simply change the array count to 2:
...and so on. Simple, right?
Now this is fine but not very efficient. Most likely, you will want to dynamically show say, 10 items at once. This can simply be achieved using cfloop and looping through the feed as many times as you want. The code to do this is:
That particular code will allow you to display up to 10 feeds. Remember that the attribute value of to should be less than or equal to the total number of items in your feed. If you specify 10 and you only have a total of 2 items in your feed, Coldfusion will throw an error.
Well then, what if you want to dynamically display the total number of items in the feed which could vary? Simply create a variable set to the total array number of your feed as such:
Then plug that variable as the attribute of to in your loop tag like so:
Now, you have a code that will dynamically display all the specified items in your feed.
Most people will probably want the title to be clickable so that it points to the actual content of the blog. That's fine. Simply go back and view the objRSS structure and look for the item link. Eventually, you're code will probably end up like this:
Congratulations! You've just dynamically integrated Blogger into your site.
Integrating Picasa photo feeds uses the same concept except you'll need to point directly to the Picasa feed album on Picasa's server since at this moment, Picasa doesn't have the ability to upload your photo album into your FTP server. You should be able to find a link to that feed when you log in to your Picasa Web Albums account. Remember though: The structure, though similar in form, will be slightly different so don't try to copy and paste the exact code above. It wont work. Make sure you traverse through Picasa's own feed structure.
That's it! Hope you find this tutorial useful.
Here's a snapshot of that site:

SETTING EVERYTHING UP:
Set up is quite easy and it starts out with you opening up a Google account if you havent already. From there, you'll be able to set up everything from your calendar, to your blogs, and your photo albums.
Setting up Google Analytics, Groups, and Checkout is easy. Just follow the simple steps in setting up your account. At the end, all you need is a snippet of code they provide that you can simply copy and paste into your pages.
For YouTube, the easiest way is to create a video playlist and copy and paste the code they provide at the end to embed the YouTube player into your page. Remember to choose the embed code, not the link to the player.
SETTING UP BLOGGER AND PICASA PHOTO FEEDS
Setting up Blogger is a bit trickier. The key thing is to set up your account to publish to an FTP site. You may find this on your Blogger dashboard under Settings > Publishing.
Once you're in the Publishing settings page, make sure you set view permissions to "Anybody" and also set the default template to "Classic" (you can always change this later). From there simply provide all your host/ftp information. Make sure that if you intend to run any sort of Coldfusion code to change the Blog File Name extension to "cfm". Hit Save Settings, submit, and publish. If all goes well, your blog will soon start publishing to your own server.
To display blog feeds/headlines, first look for the rss.xml feed file usually located in the root directory of your Blog File Path. Once you have that information, use the following code on your page to parse the xml feed so that you'll be able to manipulate it later:
<cfhttp url="http://www.yourdomain.com/your_blog_file_path/rss.xml" method="get">
This will let enable you to grab the feed via cfhttp. You can then use, xmlParse to create an rss object and parse the xml feed:
<cfset objRSS=xmlParse(cfhttp.filecontent)>
To temporarily view the contents of this object, use:
<cfdump var="#objRSS#">
That will give you a glimpse of the actual contents of the feed in an easy to view structured format. From there, you can easily figure out how to display the right content by traversing through the "branches" using dot notation. You're essentially drilling down to get to your content much like trying to get to a particular file located in a series of subdirectories. For example, to display the title of the first blog on the list, simply output the following:
#objRSS.rss.channel.item[1].title.XmlText#
To display the second one, simply change the array count to 2:
#objRSS.rss.channel.item[2].title.XmlText#
...and so on. Simple, right?
Now this is fine but not very efficient. Most likely, you will want to dynamically show say, 10 items at once. This can simply be achieved using cfloop and looping through the feed as many times as you want. The code to do this is:
<cfloop index="i" from="1" to="10">
#objRSS.rss.channel.item[i].title.XmlText#
</cfloop>
That particular code will allow you to display up to 10 feeds. Remember that the attribute value of to should be less than or equal to the total number of items in your feed. If you specify 10 and you only have a total of 2 items in your feed, Coldfusion will throw an error.
Well then, what if you want to dynamically display the total number of items in the feed which could vary? Simply create a variable set to the total array number of your feed as such:
<cfset variables.itemLength = arraylen(objRSS.rss.channel.item)>
Then plug that variable as the attribute of to in your loop tag like so:
<cfloop index="i" from="1" to="#variables.itemLength#">
#objRSS.rss.channel.item[i].title.XmlText#
</cfloop>
Now, you have a code that will dynamically display all the specified items in your feed.
Most people will probably want the title to be clickable so that it points to the actual content of the blog. That's fine. Simply go back and view the objRSS structure and look for the item link. Eventually, you're code will probably end up like this:
<cfloop index="i" from="1" to="#variables.itemLength#">
<a href="#objRSS.rss.channel.item[i].link.XmlText#">
#objRSS.rss.channel.item[i].title.XmlText#
</a>
</cfloop>
Congratulations! You've just dynamically integrated Blogger into your site.
Integrating Picasa photo feeds uses the same concept except you'll need to point directly to the Picasa feed album on Picasa's server since at this moment, Picasa doesn't have the ability to upload your photo album into your FTP server. You should be able to find a link to that feed when you log in to your Picasa Web Albums account. Remember though: The structure, though similar in form, will be slightly different so don't try to copy and paste the exact code above. It wont work. Make sure you traverse through Picasa's own feed structure.
That's it! Hope you find this tutorial useful.




