It’s wonderful to see a lot of our users taking us up on our offer to merge our Blogger Profile with the Google+ Profile. For developers this means that there is one small wrinkle to worry about - the format of the ProfileId for these migrated users has changed.
ProfileId
What’s a ProfileId, and what’s it used for?
The ProfileId is a component of the path for the Retrieving a List of Blogs Blogger GData protocol call, which can either be the value default, which is the recommended value and means the currently authenticated user, or alternatively it can be the profile identifier of the current authenticated user. Up until now, the profile identifier has always been numeric, but for the converted Google+ Profile Blogger users, this is no longer the case.
default
For users that have converted to using Google+ Profiles on Blogger, the ProfileId can be derived as follows. Take the Google+ profile url for a user that has chosen to convert, for example https://plus.google.com/114895967455102275039/, then take the numeric portion at the end of the URL, prepend it with a g, and like magic, you have the new Blogger ProfileId.
If you have any questions, please do not hesitate to ask on the Blogger Developers group, and if you are on Google+, have a look at our Blogger Google+ Page.
Many Bloggers put a lot of time and effort into creating a unique look for their blog, so today we’re excited to announce that custom templates are now also viewable from mobile devices.
If you have a custom template for your blog and want it to appear on mobile browsers as well, visit the “Template” tab of your dashboard, click on the gear icon beneath the mobile template preview.
Then select “Custom” from the “Choose mobile template” pulldown.
Your template may not look exactly the same on a mobile browser, so click “Preview” to make sure it appears the way you want it to before you save it.
If you have gadgets on your blog, you can also control which of them will be available in mobile view, using this new attribute: mobile in <b:widget> tag. It can be 'default', 'yes', 'no', or 'only'.
mobile
<b:widget>
'default'
'yes'
'no'
'only'
The widgets that display on mobile by default are the following:
The following widget will not be available in mobile view, because it’s a BlogArchive widget.
<b:widget id='BlogArchive1' title='Blog Archive' type='BlogArchive'>
To make it available in mobile view, add mobile=’yes’ attribute to it.
mobile=’yes’
<b:widget id='BlogArchive1' mobile='yes' title='Blog Archive' type='BlogArchive'>
Setting mobile to 'no' makes a widget not display in mobile view, even if available in mobile view by default.
<b:widget id='Attribution1' mobile='no' title='Attribution' type='Attribution'>
You can also make a widget available only in mobile view by setting it to 'only'.
<b:widget id='BlogArchive1' mobile='only' title='Blog Archive' type='BlogArchive'>
The content of a widget can modified for mobile view with the boolean variable data:blog.isMobile.
boolean
data:blog.isMobile
<div class="widget-content"> <b:if cond="data:blog.isMobile"> <!-- Show a text link in mobile view.--> <a href="http://www.blogger.com"> Powered By Blogger </a> <b:else/> <!-- Show an image link in desktop view.--> <a href="http://www.blogger.com"> <img expr:src="data:fullButton" alt="Powered By Blogger"/> </a> </b:if> </div>
The above template HTML shows different contents between desktop view and mobile view, depending on the value of the data:blog.isMobile variable.
You can conditionally give different CSS properties to a same class between desktop view and mobile view, as the <body> tag of Blogger mobile templates has mobile as its class. First, make sure the <body> tag of your custom template is same as the following one.
<body>
<body expr:class='"loading" + data:blog.mobileClass'>
Then, you can define different CSS properties for desktop and mobile view.
/* For desktop view */ .date-posts { margin: 0 -$(separator.outdent); padding: 0 $(separator.outdent); } /* For mobile view */ .mobile .date-posts { margin: 0; padding: 0; }
We hope you will enjoy making your very own mobile templates.
Updated: Changed data:mobile to data:blog.isMobile
data:mobile
Today we have made a change to the Layouts Template language to improve Google Analytics coverage. We have added the following includable section.
<b:includable id='google-analytics' var='blog'> <b:if cond='data:blog.analyticsAccountNumber'> <script type='text/javascript'> var _gaq = _gaq || []; _gaq.push(['_setAccount', '<data:blog.analyticsAccountNumber/>']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = (document.location.protocol == 'https:' ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </b:if> </b:includable>
This now allows you to include analytics tracking on your blog by adding the following include call to your template, preferably right before the close body tag so it doesn’t delay the visible page being rendered:
<b:include name='google-analytics' data='blog'/>
For more details on the benefits you get from using Google Analytics, see this post on Blogger Buzz. If you have any questions about this new functionality, please join in the discussion on the Blogger Developer Group.
<html> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script> // Request an API Key for the Blogger API from // https://code.google.com/apis/console/ var apikey = "YOUR API KEY HERE"; // You can find the blogId in the HTML source of a blog var blogId = "2399953"; // When the document is loaded $(document).ready(function() { // Make a JSONP request for the Posts on the Blogger Buzz blog $.ajax({ url:"https://www.googleapis.com/blogger/v2/blogs/”+ blogId+”/posts?key="+apikey, dataType: "jsonp", success: function(data, textStatus, jqXHR) { var items = []; // Construct a chunk of HTML for each post // containing the Post title, content, and a // link to the post author. $.each(data.items, function(index, value) { items.push("<h2>"+value.title+"</h2>"+value.content+ "<p>Posted by <em><a href='"+value.author.url+"'>"+ value.author.displayName+"</a></em></p>"); }); // And finally, append the generated content to the page body. $(items.join('')).appendTo('body'); } }); }); </script> </html>
It is important to understand that this release is the first step on a journey of discovery, as we work with all of you to build a better API for using Blogger. Please review the documentation, and join in the discussion on Blogger Developer Group and let us know what we can add to the API to make it more useful for you!