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 »

Download Free Windows XP SP3 Diamond Ultimate 2010 v3.0 [torrent]

0 comments



Windows Diamond Ultimate 2010 v3.0 | 695 Mb
A Little late to post One Operating System from microsoft windows,Windows Diamond Ultimate 2010 v3.0.This Operating System has been modified from Original Windows XP SP3 with added some useful softwares.
check info :
To ensure that Windows runs Diamond secure, security and stability the most. Win was integrate the latest hotfix package, and to help win this run stability and strengthen security against the infection of malicious code for Win, increase the maximum ability to protect against the message software, ad software and steal information, protect against virulent websites. Increasing protection against viruses, worms and trojans.
Optimization system increased stability to Win.
You can use it with many goals as music, movies, for office applications, graphics, games, etc. ...
Includes:
- Partition Magic 8.05
- Norton Ghost 11.5.0.2165
- HDAT 2 Toate
Programs Added :
* Mozilla Firefox v3.5.2 Plugins
* WinRAR v3.9.5 Plus (10 Theme)
* Shock 4 Way 3D v1.29
* Diamond Circle Dock v0.92
* Diamond Click star 2 v1.0.5e
* Diamond ViStart v2.0
* Diamond Sidebar v4.0
* Diamond Rocket Dock v1.3.5
* Diamond Drive Icon v1.4
* Diamond Sceen Savers v4.0
* Diamond Cursors AIO v1.9
* Diamond TrueTransparency v1.0
* Diamond Superbar v1.0.0.1182
System requirements :
CPU: P4 2.0 Ghz (or higher)
RAM: 1 GB (or higher)
VGA: Onboard 64 (greater)
HDD: 20 GB (or higher)


Continue Reading »

How To Install SPBshell windows 8 skin on nokia symbian phones

0 comments



Hi friends today I am come with a trick from a very different field.
So today I am going to tell you that how to change your symbian mobile home screen to window 8 home screen of Nokia Lumia series phones.
This is a SPB shell skin specially modified.
Supported devices : Nokia 500, 601, 701, 5800, 5230, 5233,
5250, C5-03, C5-04, C5-05, C6, C6-01, C7, N8, N97,
E7, ORO and Including S60v5, S^3, Symbian ANNA,
Symbian Belle and Belle Fresh devices.

Screen shots of mango os 8.0.































































































































































































































Advantages of This SPBSHELL Skin

  •  Turn your symbian phone in to windows.
  •  Fresh new looks you will love it.
  •  Advanced task manager allow you to close application by clicking cross.
  •  You can add more tiles in different colors.
  •   Fully editable.
  •   Rich icon set.
  •   Lumia theme and theme effects included with package.



How to setup this theme
  •  1st of all you need to download SPBshell if you don’t have.
  •  Click here to download SPBshell.
  •  Then after downloading SPBshell you need to download mango os 7.5
  •  Click here to download mango os 7.5.
  •  After downloading close the SPBshell app if running.
  •  Then extract downloaded file any where you want.
  •  You will find a SBPshell folder copy this folder in Memory card >other folder.
  •  If you want to use windows 7.5 version then run spb shell and restore settings(to restore settings go   to SPBShell settings tap on bottom right icon now you will see restore settings option you will find   mango os 7.5 by ace.set settings in restore settings folder you downloaded.)
  •  But if you want to use SPBshell mango os 8.0 by ace then continue to this step after placing SPBshell folder in memory card > others.
  •  Download Mango os 8.0 files here. Or Download Mango os 8.0.sisx
  •  After downloading the files extract it any where you want.
  •  Then run SPBshell and restore settings (to restore settings go to SPBShell settings tap on bottom right icon now you will see restore settings option you will find mango os 8.0 by ace.set settings in restore settings folder you downloaded.)
  •  That’s it you ready to feel the taste of windows 8 user interface in your symbian phone.
  •  If you are facing any problem then comment here.
If you like our post please share it with your friends.
Continue Reading »

WWE SMACKDOWN VS. RAW 2010 JAVA GAME FREE DOWNLOAD

0 comments
Continue Reading »

NEW & AWESOME SMILES CODES FOR FACEBOOK 2013

0 comments

Hello friends Facebook has everything best but It do not have enough smileys , without smiley codes chat is not be interesting , before peoples were addicted of yahoo and not before but now also some are addicted of yahoo because of smiley codes ,In yahoo messenger too much smiley codes, Smiley codes make your chat experience awesome they are your expression in chat , so today i like to share with you some awesome smiley code for your Fb chat.




The Above smiley Codes are here , Try it -




 [[f9.laugh]]
[[f9.sad]]
[[f9.angry]]
[[f9.sleepy]]
[[f9.shock]]
[[f9.kiss]]
[[f9.inlove]]
[[f9.pizza]]
[[f9.coffee]]
[[f9.rain]]
[[f9.bomb]]
[[f9.sun]]
[[f9.heart]]
[[f9.heartbreak]]
[[f9.doctor]]
[[f9.ghost]]
[[f9.brb]]
[[f9.wine]]
[[f9.gift]]
[[f9.adore]]
[[f9.angel]]
[[f9.baloons]]
[[f9.bowl]]
[[f9.cake]]
[[f9.callme]]
[[f9.clap]]
[[f9.confused]]
[[f9.curllip]]
[[f9.devilface]]
[[f9.lying]]
[[f9.rofl]]
[[f9.billiard]]
[[f9.cakepiece]]
[[f9.rosedown]]
[[f9.shutmouth]]
[[f9.shy]]
[[f9.silly]]
[[f9.tongue1]]
[[f9.fastfood]]
[[f9.ring]]

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 »
 
Sohoz-Tech