Saturday, 7 February 2015

Add links to a pages based menu on Blogger

0 comments
The pages widget on Blogger is very useful for use as menu, however, it has a weakness: you can’t add links directly from the panel, but this is possible from the code.
Step by step:

1. Go to your template code (Desktop → Design → Edit HTML) and expand widget templates.

2. Search the pages widget code, it looks more or less as follows:

<b:widget id='PageList1' locked='true' title='Pages' type='PageList'> <b:includable id='main'> <b:if cond='data:title'><h2><data:title/></h2></b:if> <div class='widget-content'> <ul> <b:loop values='data:links' var='link'> <b:if cond='data:link.isCurrentPage'> <li class='selected'><a expr:href='data:link.href'><data:link.title/></a></li> <b:else/> <li><a expr:href='data:link.href'><data:link.title/></a></li> </b:if> </b:loop> </ul> <b:include name='quickedit'/> </div> </b:includable>
To facilitate the search, can search with your browser: id = ‘PageList
3. Once you locate the code, there are two places where you can put new links:
  • Before <ul>. The link will be the first one in the menu.
  • After </ul>. The link will be the last one in the menu.
As this is an HTML list, the link will follow this format:

<li><a href='http://mysite.com/mylink/'>My link</a></li>

You can add as many links as the design permits. Always taking care of opening and closing tags correctly.
4. Save the changes.

In this way you can add links to a important label, an external site, the feed url or any other link.
Continue Reading »

HOW TO REMOVE "POWERED BY BLOGGER" ATTRIBUTION GADGET IN BLOGGRE

0 comments




The attribution gadget is a gadget present at footer of blog and says "Powered by Blogger".The gadget is locked,when you click on the edit link of attribution gadget you will notice that there is no Remove link,Because the gadget is locked officially by the blogger.To unlock the gadget follow my below easy steps carefully.

How To Remove Blogger Attribution Gadget


  • Go to Blogger Dashboard > Design > Edit HTML.(In new U.I it is Dashboard > Template)
  • As always download a copy of your template
  • Tick "Expand Widget Templates" check box
  • Now search for below code in your template



<b:widget id='Attribution1' locked='true' title='' type='Attribution'>

Replace locked='true' with locked='false'

Now save your template and go to Layout page. .
Click on the edit link of attribution widget. 




Hit Remove button and you are done.


Thats all......
Continue Reading »

Migrate from Drupal to Blogger

0 comments
For this new version of our blog we decided to migrate from Drupal to Blogger. Drupal is a great and versatile CMS, but Blogger offers several advantages to us.

Blogger advantages over Drupal

  • Blogger is free.
  • Blogger doesn’t require any maintenance.
  • Drupal is not well suited to shared hosting and performance suffers from it, meaning you either have to spend time optimizing it to perform well or you need to spend more money to host it.
  • Less time spent on security and performance, means more time to focus on content.
  • Blogger is complex enough to allow the necessary customization and branding for most blogs, while simple enough that you don’t need to spend a lot of time configuring it.

Drupal advantages over Blogger

  • Drupal is a full CMS, with all that comes with it.
  • You can build custom functionality or install a third party plugin to extend it. Blogger widgets in comparison are very limited and there are a lot of things you just can’t do with Blogger.
  • Drupal is better suited to multilanguage scenarios (we will explain how we overcame this in Blogger in a new article).
  • With Blogger you’re limited to what you can do on the client side. Things like generating sitemaps, conditionally showing ads or redirecting based on the user country become more cumbersome to do.

How to migrate from Drupal to Blogger

Migrating from Drupal to Blogger wasn’t very hard, but it was time consuming.

Migrating content and comments

I used the drupal2blogger script (by Nico Schlömer) to export the content from Drupal. Because I had different content types than the default ones and because we have content in more than one language, I had to tweak the script a little bit. The script is fairly simple and if you know PHP you should be able to accommodate it to your needs.
We used and still use Disqus for the comments, so the migration for the comments was done separately (we will explore that in a future article).

Updating HTML and links

The most time consuming part was updating the HTML and internal links in the content. I guess that’s part of any migration.
We wanted to clean up the HTML, add some common structure (for attachments, article to article navigation in a series, etc.) and change the syntax highlighter. We automated as much as most we could through regexes, but there was still the need to manually correct each article.

Migrating images and attachments

Images were somewhat painful to migrate, because we had to update each source. When you create a blog in Blogger, a Picasa web album will be automatically created for you. You can store the images there freely.
Attachments were not that complicated, since we didn’t have that many. We created a public folder in Google Drive and place all our files there. Then for each attachment you have to get the direct link to the Google Drive file.

Redirects in Blogger

Blogger allows you to create redirects (Settings > Search preferences > Errors and redirections > Custom Redirects), which is essential since we’re migrating to a different URL scheme and don’t want to lose any traffic.
I had to set up over 300 redirects. To do this, I used a wonderful tool called iMacros for Chrome, which basically helps you automate things like form filling. I made one big script and let it run on the browser.

Sitemap

Generating the sitemap ended up being easier than expected. You can use the Blogger Sitemap Generator, which basically generates the robot.txt code and uses the atom feed of your blog.

Conclusion

Those were the basic steps we took to migrate. We built a new layout, so we had no intentions to migrate the old look. In any case, it would be a lot of work to migrate a Drupal template to a Blogger one, so making a new one makes more sense.
If you are starting a new blog and are considering between Drupal and Blogger, think seriously if Drupal is what you really want. Only in very specific circumstances will Drupal be better for a blog. We chose Drupal in the past because we wanted more control and Blogger wasn’t as mature as it is now, but there is a price in complexity.
If you are using Drupal, know that you can migrate to Blogger when you want. It comes with a cost, but it is certainly feasible.
Continue Reading »

Disqus comment migration to new domain or platform

0 comments
We have recently migrated from Drupal to Blogger. We used and are still using Disqus as the commenting platform for our blog. Because the paths (URLs) for our articles have changed, we had to do a migration for the comments as well.

Disqus tools for migrating threads

Disqus offers several tools to help with comment migration based on domain or path changes:
  • Domain Migration Wizard: use when the only thing that changed is the domain (paths to articles remain the same).
  • Upload a URL map: provide a CSV file which maps old paths with new paths.
  • Redirect Crawler: if you’ve set up 301 redirects for all your paths, this crawler will automatically map old paths with new ones.

How we migrated Disqus threads

Though we had set 301 redirects for our old paths, not all articles were covered by this, so we couldn’t use the Redirect Crawler.
The redirects that you can set up in Blogger have a limitation: you cannot redirect to a different domain. We have a multilingual blog and because we are now using a sub-domain for the Portuguese blog, we cannot properly redirect the old Portuguese paths (www.broculos.net/pt/...) to the new sub-domain (pt.broculos.net/...), so the Redirect Crawler was out of question.
To migrate the threads, we built a CSV file with mappings from the old paths to the new paths, which was pretty straightforward:

http://www.broculos.net/en/article/as400-chapter-1-introduction,http://www.broculos.net/2007/10/as400-chapter-1-introduction.html
http://www.broculos.net/en/article/as400-chapter-2-commands,http://www.broculos.net/2007/10/as400-chapter-2-commands.html
http://www.broculos.net/en/article/as400-chapter-3-libraries,http://www.broculos.net/2007/10/as400-chapter-3-libraries.html
...

Missing threads and how Disqus works

After using the URL map tool we still had a lot of articles without comments and we couldn’t figure out why. At this point, it’s important to understand how Disqus identifies threads and relates them to pages.
Disqus uses the Disqus identifier, that you can pass to the Disqus script with a JavaScript configuration variable named disqus_identifier. This identifier is what determines the appropriate thread to load.

It’s not mandatory to use the Disqus identifier, but if you define it in a page, Disqus will use that to load the thread. If it isn’t defined, Disqus will use the page’s URL.
The migration is supposed to map the old path to the new ones, but we found that there were a lot of threads with an empty path and, because of that, they couldn’t be migrated using Disqus tools. The only way to identify them was with the Disqus identifier.
How did we find that the threads had an empty path? When we started to investigate why the migration had failed for some articles, we used the Disqus Export tool, which exports all threads and comments in an XML format.

By inspecting the XML file, we found out the threads that had missing paths and their respective identifier. What we then do is, for all the pages with missing comments, we manually define the identifier and pass it to the Disqus script.

Somewhere on your page (before the Disqus script is loaded) you can identify the thread in this way:
var disqus_identifier = "id";
We did this for all the pages with missing threads and the problem was solved.
Continue Reading »

How to use Google Drive to share files in your blog

0 comments
You can use Google Drive to store public files for download in your blog and also to store CSS and JS files that you can use in your blog’s template.
Since we migrated to Blogger, we had to deal with where we were going to store article attachments. Another concern was where to store the CSS and JS files that we use in our design.
Blogger doesn’t offer any storing space, but it turns out that Google Drive is perfect for both cases.

How to store files in Google Drive for public download

This is how we did it for article attachments:
  • Create a new folder in Google Drive.
  • Go to the sharing settings and change the visibility and access options.
  • Set “Anyone with the link” and “Can view”.
  • Place files in the shared folder, they will inherit the folder’s permissions.

How to get a download link for a Google Drive file

Now you can store files in the shared folder, but Google Drive doesn’t give you a direct download link, only a link to a Google Drive page where you can see the file.
To get a direct link for a Google Drive file do the following:
  • Go to the sharing settings of the file.
  • Copy the URL. It should be something like this:
    • https://docs.google.com/file/d/0Bxp1PlM4alaxOTl6SFM1OTloUUk/edit?usp=sharing
  • Extract the ID of the file.
  • To get a direct download URL, build the following URL with the extracted ID:
    • https://drive.google.com/uc?export=download&confirm=no_antivirus&id=0Bxp1PlM4alaxOTl6SFM1OTloUUk
  • To get a link to open the file directly:
    • https://drive.google.com/uc?export=&confirm=no_antivirus&id=0Bxp1PlM4alaxOTl6SFM1OTloUUk

How to store CSS and JS files in Google Drive for your blog

It turns out that you can store an HTML website in Google Drive. We used that functionality to store the CSS and JS files that we link to in our Blogger’s template.
How to host a website in Google Drive:
  • Create a folder.
  • Go to the sharing settings and change the visibility and access options.
  • Set “Public on the web” and “Can view”.
  • Place files (HTML, CSS, JS) in the folder.

How to link to HTML, CSS or JS files stored in Google Drive

Now that you’ve placed your website’s files in Google Drive, you can link to them in the following way:
  • Go to the sharing settings of the folder.
  • Copy the URL. It should be something like this:
    • https://drive.google.com/folderview?id=0Bxp1PlM4alaxVHhGdmhobEtQOE0&usp=sharing
  • Extract the ID of the folder.
  • Now you can link to the files by building a URL in the following manner:
    • https://googledrive.com/host/0Bxp1PlM4alaxVHhGdmhobEtQOE0/style.css
  • You append the ID of the folder and then the filename.

Conclusion

There are other alternatives besides Google Drive, but if you’re already using Blogger like us, using Google Drive to store files for your blog is pretty straightforward.
Continue Reading »

How to create a multilingual blog in Blogger

0 comments
Blogger doesn’t offer multilingual features, but we will show you how, with some tricks, you can create a multilingual blog.
As you can see at the right side, we offer our blog in more than one language and we achieved this using standard Blogger. Our strategy was pretty simple:
  • Create a separate blog for each language/country.
  • Configure each blog with the same template and settings, with the exception of the language and formatting, which should obviously be specific for each language/country.
This works best when you have a custom domain and you can create sub-domains for each language. In our case the www sub-domain points to the (default) English blog and the pt sub-domain points to the Portuguese blog.

Block with language links/redirects

Now, the tricky part is you have to create each article and each page with the same permalink (URL) on all your language blogs. Blogger allows you to customize the permalink when you first create a article/page or when you revert a page/article back to draft.

Blogger permalink settings

This will be key to offer proper language links/redirects based on the user language. Here is the code for your language block:
<div class='content-block' id='language'>
    <div class='block-wrapper'>
        <h3>Select language</h3>
        <ul>
            <li>English,</li>
            <li><a href='http://pt.broculos.net'>Português</a></li>
        </ul>
        <script type='text/javascript'>
            //<![CDATA[
                var a = document.URL.replace(document.domain, "pt.broculos.net");
                $("#language li > a").attr("href",a);
            //]]>
        </script>
    </div>
</div>
As you can see, we build each language link with some JavaScript code that picks the current URL and replaces the language’ specific sub-domain. A very simple thing, but it requires discipline when creating new articles/pages.

Limitations

There are some limitations to this approach. It requires JavaScript and, in our case, we decided not to do any automatic redirection based on the visitor’s country or browser settings.
You can do the automatic redirection in JavaScript, but you will need an external server to properly determine the visitor’s country and language settings and we decided it was not worth the hassle.
Continue Reading »

How to create your own Blogger template from scratch

0 comments
This article is for people who already have knowledge in HTML and CSS, but are new to Blogger templates.

How do Blogger templates work?

Bloger templates are XML files which include everything about the layout. Listings, static pages, blog posts, search pages, content block, you name it, it’s there. Even the CSS and JavaScript is in there.
On the other hand, you can also use Google Drive for storing CSS and Javascript files.
Although you put all your HTML into the XML template as you would in any other HTML page, it is still an XML definition, so XML syntax rules apply.

The anatomy of a Blogger template

If you download a Blogger template and look at its code, you’ll see that, although you have the XML header in the very beginning, the root element is the HTML tag. Inside you’ll find the usual suspects: head and body. A very familiar way to start, the differences start after that.

Head Section

In the head section you’ll find the Blogger skin elements (<b:skin><b:template-skin>), among other things. Inside the skin elements you’ll find the CSS for the template.
You can delete the <b:template-skin> section and leave the <b:skin> empty if you’re going to use your own styles.
<b:skin>
<![CDATA[ /* CSS styles */ ]]>
</b:skin>

If you’re not using an external CSS file, then insert your CSS into the skin section.
As we mentioned before, this is an XML file, so CSS will not parse correctly. That’s why we use the CDATA wrapper.

Body Section

Here you’ll find the main elements: section, widget, includable and all the HTML structure.
<b:section class='main' id='main' preferred='yes' showaddelement='no'>
<b:widget id='Blog1' locked='false' title='Blog Posts' type='Blog'>
<b:includable id='nextprev'>
...
</b:includable>
<b:includable id='main' var='top'>
...
</b:includable>
<b:includable id='status-message'>
...
</b:includable>
<b:includable id='post' var='post'>
...
</b:includable>
</b:widget>
</b:section>

The body can have HTML, CSS or JavaScript code and one or more sections.
A section can only have widgets and a widget has to have one or more includable elements, and only includables.
In the includable is where you can add any HTML, CSS or JavaScript code.
If you look in the Layout section of you Blogger administration pages you can see the structure of the page with different sections and widgets. These are the same you find in the XML template. If you change the XML to edit, remove or add new sections and widgets it will reflect on this page.

Widgets

Widgets need to have at least one includable with id=”main”. This is where the bulk of the action happens. You can have other includables in a widget, but you need to explicitly call them for their code to be executed:
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<b:include name='nextprev'/>
</b:if>

You can look at includables as ways to divide the code in logical chunks (sort of like functions).
Inside includables you can use any code you want. Bellow you can see an example of a widget of type HTML. But you can also customize the code of other widget types, as long as the code is in the template you can change it.
<b:widget id='HTML1' locked='false' title='Follow Us' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<div id="follow" class="block">
<h2 class="title"><data:title/></h2>
<ul>
<li class="rss">
<a href="#">RSS</a>
</li>
<li class="facebook">
<a href="#">Facebook</a>
</li>
<li class="gplus">
<a href="#">Google+</a>
</li>
</ul>
</div>
</b:if>
</b:includable>
</b:widget>

One useful thing to know about widgets is that their id needs to be its type (above is HTML), followed by a number. This number needs to make this id unique in the template.

Targeting pages. Conditions and loops

You can have conditional bits of code inside the body tag or inside an includable element. This way you can target different page types (listings, blog posts or static pages).
This is how you target a listing page:
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<!-- do something on a listing page -->
<b:else/>
<!-- do something else on all other pages -->
</b:if>

Available values in data:blog.pageType property:
  • item
  • archive
  • index
  • static_page
You can even be more specific and target specific pages by URL, like so:
<b:if cond='data:blog.url == &quot;http://www.broculos.net/p/tags.html&quot;'>
<!-- Stuff for the tags page -->
</b:if>
Or use Blogger’s data to target the homepage, for example:
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<!-- Stuff for the homepage -->
</b:if>
You can loop through lists of data, like so:
<b:loop values='data:posts' var='post'>
<b:include data='post' name='post'/>
</b:loop>

Blogger data
You can pickup data from Blogger using the <b:data> element. Use it to get tags, titles, dates, URLs. This tag is context specific, so if you’re handling a blog post you’ll get different data than if you’re handling an HTML widget. See an extensive list of layout data tags here.
An example of showing all the labels from a post:
<b:if cond='data:post.labels'>
<ul class="tags">
<b:loop values='data:post.labels' var='label'>
<li>
<a expr:href='data:label.url + "?max-results=5"' rel='tag'><data:label.name/></a>
</li>
</b:loop>
</ul>
</b:if>

Continue Reading »

Blogger: How to get the images in listings to link back to the post

0 comments
Images in Blogger posts, by default, are wrapped by an anchor. This anchor will either open the image in a new window, or open a lightbox with the image (either you have this setting activated or not). This is the standard behavior in the post page or in the posts listing page.

Usability wise this is pretty crappy. Users expect the image to link back to the page it refers to in a list of articles. You don’t want to get your users angry because your site doesn't work as they expect.
Here’s what you have to do to make the image link to the post.
Include this code in the <head> section of your post, or if you have a dedicated scripts file you can place the linkListImagesToPosts() function there. You can host your script on your Google Drive account.
The call to the function should still be in the head, because we only want to target the index pages, and we can only use conditions in the template file (line 2).
 <script src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'/> 
 <b:if cond='data:blog.pageType == &quot;index&quot;'> 
 <script  type='text/javascript'> 
 //<![CDATA[ 
    function linkListImagesToPosts() { 
         $(".blog-posts .post-outer").each(function(index) { 
                 // get the post url from the title anchor 
                 var newhref = $(this).find("h3.post-title a").attr("href"); 
                  
                 // find the image anchor and clone it 
                 var a = $(this).find("img").first().parent("a"); 
                 var aclone = a.clone();         
                  
                 // change the link in the image anchor 
                 aclone.attr("href", newhref); 
                  
                 // replace the old anchor with the new one 
                 a.replaceWith(aclone); 
         }); 
    } 
    $(document).ready(function() {                 
         linkListImagesToPosts(); 
    }); 
 //]]> 
 </script> 
 </b:if>
The linkListImagesToPosts() is very simple, we loop through all the posts, and for each post we strip the URL from the title anchor and we’ll copy that URL into the image anchor.
Important Note: if you change the HTML in your template you might need to reflect that in the selectors.

clone() usage

There’s a problem with simply replacing the href value in the image anchor. If the blog is using lightbox, its scripts will attach an event to the anchor that will prevent the anchor from triggering the href redirect.
So even if you’re able to change the href, the anchor will still show the lightbox when you click it.
We solve this problem by using jQuery clone() function. The copy object will not carry the attached events, so all we need to do is change the href in this object and replace the original anchor with its clone.
Continue Reading »

How to create a tabbed navigation for recent and popular posts in Blogger

0 comments
A section with tabs to list different posts (popular, recent, comments, etc) is a very common feature in blogs and sites.

I’ll show you how to implement the popular / recent tabs in a blogger template. This is what we want to achieve:


If you don’t know how add the recent posts listing to your blog read first my article on how to add a recent posts gadget to Blogger.
You’ll also need to add references to jQuery and jQueryUI to your Blogger template.
You need to already have the Popular Posts gadget included in your template. If you don’t have it, include it in the section you want.

Next, in your Blogger administrator page go to Template (on the right side). Click the “Edit HTML” button. Copy all the code into an xml file in your computer.
Let’s edit this file.

Search for the PopularPosts widget in the file. Replace it with the following (when replacing the widget make sure to use the same widget ID you had before):
<b:widget id='PopularPosts1' locked='false' title='Popular Posts' type='PopularPosts'>
<b:includable id='main'>
<div class="block">
<div id="tabs">
<ul>
<li><a href="#popular-posts">Popular</a></li>
<li><a href="#recent-posts">Recent</a></li>
</ul>
<div id="popular-posts">
<div class='widget-content popular-posts'>
<ul>
<b:loop values='data:posts' var='post'>
<li>
<b:if cond='data:showThumbnails == &quot;false&quot;'>
<b:if cond='data:showSnippets == &quot;false&quot;'>
<!-- (1) No snippet/thumbnail -->
<a expr:href='data:post.href'><data:post.title/></a>
<b:else/>
<!-- (2) Show only snippets -->
<div class='item-title'><a expr:href='data:post.href'><data:post.title/></a></div>
<div class='item-snippet'><data:post.snippet/></div>
</b:if>
<b:else/>
<b:if cond='data:showSnippets == &quot;false&quot;'>
<!-- (3) Show only thumbnails -->
<div class='item-thumbnail-only'>
<b:if cond='data:post.thumbnail'>
<div class='item-thumbnail'>
<a expr:href='data:post.href' target='_blank'>
<img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
</a>
</div>
</b:if>
<div class='item-title'><a expr:href='data:post.href'><data:post.title/></a></div>
</div>
<div style='clear: both;'/>
<b:else/>
<!-- (4) Show snippets and thumbnails -->
<div class='item-content'>
<b:if cond='data:post.thumbnail'>
<div class='item-thumbnail'>
<a expr:href='data:post.href' target='_blank'>
<img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
</a>
</div>
</b:if>
<div class='item-title'><a expr:href='data:post.href'><data:post.title/></a></div>
<div class='item-snippet'><data:post.snippet/></div>
</div>
<div style='clear: both;'/>
</b:if>
</b:if>
</li>
</b:loop>
</ul>
<b:include name='quickedit'/>
</div>
</div>
<div id="recent-posts">
<div class='widget-content popular-posts'>
<div id="recentposts"> </div>
<script type="text/javascript">
displayRecentArticles({'containerSelector': '#recentposts'});
</script>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs();
});
</script>
</div>
</b:includable>
</b:widget>

What I changed:
  • Wrapped some divs around the Popular Posts code
  • Added a div for the recent posts, just after the popular posts
  • Added the ul for the tabs’ header (as per jQueryUI requirements)
  • Added the script to make the #tabs div a jQueryUI tabbed interface.
Don’t forget:
  • Include the jQuery and jQueryUI files in the <head> section
  • The recent posts list will only work if you follow these instructions.
Continue Reading »

How to add a recent posts widget to Blogger

0 comments
Unfortunately Blogger doesn’t provide a recent posts widget out of the box, as it does with the popular posts widget.
I’ll show how to add a custom widget to your Blogger site, with a reusable and configurable script that will load the recent posts for you.

jQuery

First you’ll need to include jQuery in your template, if you haven’t already.
In the head section of your template paste the following line (if you want to use the latest jQuery version).

<script src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'/>

HTML/Javascript widget

Now add a new HTML/Javascript widget to the area where you want the posts to appear. Paste the following code into the widget.

<div id="recentposts"> </div> <!-- where the posts will be loaded into-->
<script type="text/javascript">
        displayRecentArticles({'containerSelector': '#recentposts'});
</script>

Javascript

I advise to use a separate javascript file for this. You can host it in your Google Drive account. Let’s call it recentposts.js.
First include the file in the head section of the template (after the call to the jQuery file):

<script src='https://googledrive.com/host/<yourfolderID>/recentposts.js' style='text/javascript' />
 
If you are using Google Drive to host the file replace <yourfolderID> with your folder id. Follow these instructions on how to get the folder ID.
Now for the code in the recentposts.js

function displayRecentArticles(userOp) {
 var op, maindiv = null, ul = null;
 op = {
  'maxPosts': 5,
  'containerSelector': '#recentposts',
  'loadingText': 'A carregar...',  
  'showpostthumbnails': true, 
  'displaymore': false, 
  'showcommentnum': false, 
  'showpostdate': false, 
  'showpostsummary': false, 
  'numchars': 100, 
  'nothumburl': 'https://lh3.googleusercontent.com/-aZ9hQT-uYcM/UqMLxTpK-8I/AAAAAAAACS0/hOHUdI2aEr4/s400/large%2520%25281%2529.jpg'
 };
 op = $.extend({}, op, userOp);
 
 function showRecentPosts(json, status) {  
  if (json.feed.entry) {
   var entry, posttitle, posturl, commenttext, commenturl;
   
   for (var i = 0; i < op.maxPosts && i < json.feed.entry.length; i++) {
    entry = json.feed.entry[i];
    posttitle = entry.title.$t;
    posturl;
    
    for (var k = 0; k < entry.link.length; k++) {
     if (entry.link[k].rel == 'replies' && entry.link[k].type == 'text/html') {
      commenttext = entry.link[k].title;
      commenturl = entry.link[k].href;
     }
     if (entry.link[k].rel == 'alternate') {
      posturl = entry.link[k].href;
      break;
     }
    }
     
    // wrapper div
    var div = $("<div class='item-thumbnail-only'></div>");
    
    // thumbnail
    if (op.showpostthumbnails == true) {
     var thumburl = getPostThumbUrl(entry);    
     div.append('<div class="item-thumbnail">' +
      '<a target="_blank" href="' + posturl + '">' + 
      '<img class="recent_thumb" src="' + thumburl + '"/></a></div>');
    }
    
    //url
    div.append('<div class="item-title">' +
     '<a href="' + posturl + '">'+ posttitle +
     '</a></div>');
    
    // content  
    if (op.showpostsummary == true) {
     var postcontent = getPostContent(entry); 
     div.append("<div class='item-snippet'>" + postcontent + "</div>");   
    }
      
    // date
      if (op.showpostdate == true) {
     var date = getPostDate(entry);
     
     div.append("<div class='item-date'>" + date + "</div>")
    }
    // comments
    if (op.showcommentnum == true) {
     var nComments = commenttext.split(" ")[0];
     
     // remove plural in Comments if nComments == 1
     if (nComments == 1) {
      commenttext = '1 Comment';
     }
     
     if (nComments == 0) {
      commenttext = 'No comments';
     }
     
     div.append('<div class="item-comments"><a href="' + commenturl + '" target ="_top">' + commenttext + '</a></div>');   
    }
    
    // show more link
    if (op.displaymore == true) {
     div.append('<a href="' + posturl + '" class="url" target ="_top">more...</a>');    
    }  
    div.append('<div style="clear: both;"></div>');
    ul.append($("<li></li>").append(div)); 
   } 
   
   $('#recent-loading', maindiv).remove();
  }
 }
 
 function getPostContent(entry) {
  var postcontent = "";
  
  if ("content" in entry) {
   var postcontent = entry.content.$t;
  } 
  else {
   if ("summary" in entry) {
    var postcontent = entry.summary.$t;
   } 
  }
  
  var re = /<\S[^>]*>/g;
  postcontent = postcontent.replace(re, "");
   
  // check for max nr of characters allowed
  if (postcontent.length > op.numchars) {
   postcontent = postcontent.substring(0, op.numchars);    
   var quoteEnd = postcontent.lastIndexOf(" ");
   postcontent = postcontent.substring(0, quoteEnd);
   postcontent += '...';
  }
    
  return postcontent;
 }

 function getPostThumbUrl(entry) { 
  var thumburl;
  
  try {
   thumburl = entry.media$thumbnail.url;
  } 
  catch (error) {
   var img = $(entry.content.$t).find("img").first();
   var imgsrc = img.attr("src");
   
   if (imgsrc != "") {
    thumburl = imgsrc;
   } 
   else {   
    thumburl = nothumburl; 
   }
  }
  
  return thumburl;
 }

 function getPostDate(entry) {
  var postdate = entry.published.$t;
  var cdyear = postdate.substring(0, 4);
  var cdmonth = postdate.substring(5, 7);
  var cdday = postdate.substring(8, 10);  
  var monthnames = ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
  
  return cdday + " " + monthnames[parseInt(cdmonth)] + " " + cdyear;   
 }
 
 function initRecentPosts() {
  // get related div
  maindiv = $(op.containerSelector); 
  
  // loading text
  $('<div id="recent-loading">' + op.loadingText + '</div>').appendTo(maindiv);
  
  // create list
  ul = $('<ul></ul>').appendTo(maindiv);
  
  // request recent articles  
  $.ajax({
   url: '/feeds/posts/default/',
   data: {
    'orderby': 'published',
    'max-results': op.maxPostsPerTag,
    'alt': 'json-in-script'
   },
   success: showRecentPosts,
   dataType: 'jsonp',
   cache: true
  });  
 } 
 initRecentPosts();
}
A few notes on this script:
  • If your blog is not in english you should change the section where I deal with the comments’ text (section after comment //comments). You might want to adapt it to your language or just remove it.
  • I’ve used as much as possible the same HTML structure as in the Popular Posts gadget. It will make styling a lot easier if you want to to use both gadgets and have them look the same.
  • If you want to change some of the options in the script you can do so by sending them in the parameters of the displayRecentArticles() function.
Now to finish it up, the bare essentials styling:
#recentposts ul {
margin: 0;
padding: 0;
list-style: none;
}
#recentposts .item-thumbnail {
float: left;
margin: 0 5px 5px 0;
}
 The result:

Continue Reading »

How to create a page in Blogger to show all tags/labels

0 comments
There’s no straightforward way to fetch all existing tags in a Blogger hosted blog or site. Today I’ll show you how to work around this issue.

Using the Blogger API the only way to get all tags is to fetch all the posts and scrape the tags, remove the duplicates, and you’re left with all the tags available in the blog. Depending on the number of posts you have, this might turn out to be a very time consuming call.

I’ll show you a better and easier way to do this using the Labels widget.
The idea here is to only show the widget on a specific page. This specific page should be created beforehand.

I use the default code for the Labels widget (you can add it to your template via Layout > Add Gadget) and wrap all the code inside the main includable with a couple of conditions to test if it’s a static_page and to check if the page name is the one where I want to show the tags.

Why these conditions? In my case I want to show the tags on a static_page so I check for that. You can see here all the available pageTypes you can use.

I also want to show the tags in a specific page named Tags. I could have chosen to check for a specific URL, using data:blog.url data property but since I have both a test and production environment it’s best for me to use the page name.

<b:widget id='Label1' locked='false' title='Labels' type='Label'>
  <b:includable id='main'>
    <b:if cond='data:blog.pageType == "static_page"'>
      <b:if cond='data:blog.pageName == "Tags"'>
        <b:if cond='data:title'>
          <h2><data:title/></h2>
        </b:if>
        <div expr:class='&quot;widget-content &quot; + data:display + &quot;-label-widget-content&quot;'>
          <b:if cond='data:display == &quot;list&quot;'>
            <ul>
              <b:loop values='data:labels' var='label'>
                <li>
                  <b:if cond='data:blog.url == data:label.url'>
                    <span expr:dir='data:blog.languageDirection'><data:label.name/></span>
                  <b:else/>
                    <a expr:dir='data:blog.languageDirection' expr:href='data:label.url'><data:label.name/></a>
                  </b:if>
                  <b:if cond='data:showFreqNumbers'>
                    <span dir='ltr'>(<data:label.count/>)</span>
                  </b:if>
                </li>
              </b:loop>
            </ul>
          <b:else/>
            <b:loop values='data:labels' var='label'>
              <span expr:class='&quot;label-size label-size-&quot; + data:label.cssSize'>
                <b:if cond='data:blog.url == data:label.url'>
                  <span expr:dir='data:blog.languageDirection'><data:label.name/></span>
                <b:else/>
                  <a expr:dir='data:blog.languageDirection' expr:href='data:label.url'><data:label.name/></a>
                </b:if>
                <b:if cond='data:showFreqNumbers'>
                  <span class='label-count' dir='ltr'>(<data:label.count/>)</span>
                </b:if>
              </span>
            </b:loop>
          </b:if>
          <b:include name='quickedit'/>
        </div>
      </b:if>
    </b:if>
  </b:includable>
</b:widget>
Continue Reading »

Metatags on Blogger

0 comments
Metatags are labels with information about our site, like the theme of the website or blog, its description, keywords, author’s information, language, among many others. They are important because help search engines and other web applications to rank your web, so if you don’t have them it makes their work even more difficult, and the result is less visits and visits that are not related with the articles.
One of the most neglected parts in Blogger are precisely the metatags, because they don’t think the proper indexing of your page is important enough. Well, in this article we’ll show you how to place the most important in the home and in the pages of the labels.
    1. Go to “Layout”, and then to “Edit HTML”.
        1. Search for the following code:
          <title><data:blog.pageTitle/></title>
            1. Under this code will be conditions to show the metatags in their own pages, according to the following code scheme:
              <!-- Home Metatags --> <b:if cond='data:blog.pageType == "index"'> <meta content='here the keywords, separated by commmas' name='keywords'/> <meta content='description of the general website content' name='description'/> </b:if> <!-- Labels Pages Metatags --> <b:if cond='"http://label-address" == data:blog.url'> <meta content='here the words taht describe this label' name='keywords'/> <meta content='description of the content of this label' name='description'/> </b:if>
Continue Reading »

Use Google Sitemap on Blogger

0 comments
One way to help Google indexing our website or blog, is by telling them the pages we have, when they’re modifiedan when we have new articles. This can be easily done using a simple tool created for this: Google Sitemap. Besides of helping you with Google indexation, this tool can give us our blog’s stats and an error report.

Thank’s to Blogger’s system and other content manager systems, using this tool is pretty simple, and now we show you how:
  1. Go to the main page of Google Sitemap, and login with your Google account (Blogger, Gmail, etc.).
  2. In the text box, write your blog’s URL. “http://yourblog.blogspot.com”.
    1. You’ll enter a panel with a warning, telling you the next step is to verify the site belongs to you. Click that link.
      1. Now it’ll show you two choices to verify your site. Choose “Add a META label” (The other one is not possible with blogger, but it is to any other CMS).
      2. After clicking, the same page show you the META label’s code. Copy this code, but don’t close this page yet. On your blog, go to “Layout” tab, and then to “Edit HTML”. Search for the following code:
      3. <head>
        And just down, paste the verification code.
      4. On Google Sitemaps, click “Verify” button. If everything is ok, your site will be shown as verified.
      5. Now, on the upper right of your screen click the “Sitemap” tab, and the “Add a sitemap”. Now it will ask you for a type, so select “Add a general sitemap”. By doing this, blogger will show a text field to write your sitemap’s URL On blogger is: http://YOURBLOG.blogspot.com/atom.xm.Replace “YOURBLOG” for your blog’s address or username, and click “Add a web sitemap”.
      With this, the service is activated, and within a couple of hours Google will start seeking for your site’s information.

Continue Reading »

Create a widget to add a link to your blog

0 comments
In this article we’ll show you how to create a widget (code segment) so that your visitors only have to press a button to add a link to your blog on their own.
1. Go to "Layout" tab.



 2. Add a "HTML/Javascript" element in the section you wanna have the button.

3. Set the title as "Add us", or any text you want for the button. You can leave it blank too, it will add some default text.

3. Paste the following code in the "Content" field:

<form action="http://beta.blogger.com/add-widget" method="post" target="_blank">
<input value="" name="widget.title" type="hidden" />
<textarea style="display: none;" name="widget.content">
<!-- Link's code -->
<a href="http://YOURBLOG.blogspot.com">TU BLOG</a>

</textarea>
<input value="Add YOURBLOG to your Blogroll" name="go" type="submit">
<input type="hidden" name="infoUrl" value="http://blog.btemplates.com/create-a-widget-to-add-a-link-to-your-blog/"/>
</form>
  1. Here you have to make some changes:
    http://YOURBLOG.blogspot.com – Your blog’s address.
    YOUR BLOG – Your blog’s name or an image’s code. It willl be shown in the Blogroll of the one who’s adding you.
    Add YOURBLOG to the Blogroll – The message you wanna show on the button.
    This code work for another CMS or webs, but it only can be added by Blogger’s users.
  2. Save the changes an it’s done.
Continue Reading »

Thursday, 5 February 2015

I sent a template, why is it not published?

0 comments
Usually we receive a big number of templates, we try to publish as soon as possible and ensure a minimum quality in the published templates in BTemplates, some of the criteria that we use to approve a templates are:
  • An acceptable graphic and technical quality.
  • Compatible with most browsers.
  • No installation errors.
  • A license that allows distribution.
Continue Reading »

What does the icon of a gold medal in some templates?

0 comments
We call them Free Premium Templates and highlight it with this icon because have an excellent graphic quality, are well designed for Blogger, bring additional features and / or are compatible with the major browsers (Firefox, Chrome, IE7).
Continue Reading »

Can I remove the template credits?

0 comments
No, the vast majority of templates are licensed under a Creative Commons, GPL or similar license, thus removing the credits would be using an illegal copy of the same. You can simplify the credits or relocate, but not remove them. Remember that the templates are free, so keep the credits is a way to thank those who designed and / or adapted the template.
Continue Reading »

Why is my blog shows few entries per page?

0 comments
Blogger recently implemented a mechanism called “auto pagination” to reduce the loading time of its blogs. This mechanism is to show less Blogger entries per page if it detects that the page is heavy to load.

To avoid that this happens, you can try to decrease the load time of your blog, some recommendations are:
  • Optimizing images. For example, using Smush.it or a free image editor like Gimp.
  • Eliminate unnecessary gadgets.
  • Use “read more” in your longer posts.
  • Optimize CSS code. For example, with CSS Optimizer.
Continue Reading »

How to display the last posts or comments on the sidebar?

0 comments
  1. Enter the administrator page elements (Dashboard → Design or Dashboard → Layout in the new Blogger design).
  2. Add a new feed widget, with the following URL’s:To show the recent posts:
    http://BLOGNAME.blogspot.com/feeds/posts/default
Continue Reading »

How to display the navbar again in my template?

0 comments
Easy! Enter in the code of your template (Dashboard → Design → Edit HTML) and search for:


#navbar-iframe {
   height:0px;
   visibility:hidden;
   display:none
}
 
Continue Reading »
 
Sohoz-Tech