Tuesday, 22 November 2011

Image zooming plugin

image zooming
 Sometime ,we need a bigger and detailed version of an image ,but size of image is limited by post frame . So we can do a zoom function for image . For example ,you have a blog that selling children apparel . Because of the limitation of post frame ,if we add a big image ,it will break out the layout .If we add a small size image ,it's hard for buyer to see product in detail . It's time for zooming function .

Download


Installing this script is not different to lightbox effect .

Now let's start

1,Download the script files and upload to your hosting . This step is required because I have no hosting in hand now .

2,Now add these line bellow before <body>

<link href="/styles/cloud-zoom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/JavaScript" src="/js/cloud-zoom.1.0.2.min.js"></script>

3,How to use
In blog posting window ,after inserting image ,click on edit HTML ,and edit the HTML code of image to this form
<a href="bigimage.jpg" class="cloud-zoom" rel="option goes here .........">
<img src="smallimage.jpg" title="Optional title display" >
</a>
Bigimage.JPG is the big and detail version of image
Smallimage.JPG is the small version of image
Class 'cloud-zoom' is required .


4,If your blog has a line for calling jquery framework ,do not add more
<script type='text/javascript' src='js/jquery.js'></script>
because more than one jquery calling can make all script stop .

5,Options can be set by adding into rel attribute . I marked where to put option by the text "option go here" in the step 3 . Each option is separated by a comma ( , ) .

Here is the list of options 

  • zoomWidth : The width of the zoom window in pixels. If 'auto' is specified, the width will be the same as the small image .
  • zoomHeight : The height of the zoom window in pixels. If 'auto' is specified, the height will be the same as the small image.
  • position : Specifies the position of the zoom window relative to the small image. Allowable values are 'left', 'right', 'top', 'bottom', 'inside' or you can specifiy the id of an html element to place the zoom window in e.g. position: 'element1'
  • adjustX : Allows you to fine tune the x-position of the zoom window in pixels.
  • adjustY :  Allows you to fine tune the y-position of the zoom window in pixels.
  • tint Specifies a tint colour which will cover the small image. Colours should be specified in hex format, e.g. '#aa00aa'. Does not work with softFocus.
  • tintOpacity :  Opacity of the tint, where 0 is fully transparent, and 1 is fully opaque .
  • lensOpacity :  Opacity of the lens mouse pointer, where 0 is fully transparent, and 1 is fully opaque. In tint and soft-focus modes, it will always be transparent.
  • softFocus : Applies a subtle blur effect to the small image. Set to true or false. Does not work with tint.
  • smoothMove : Amount of smoothness/drift of the zoom image as it moves. The higher the number, the smoother/more drifty the movement will be. 1 = no smoothing.
  • showTitle : Shows the title tag of the image. True or false. true
  • titleOpacity : Specifies the opacity of the title if displayed, where 0 is fully transparent, and 1 is fully opaque. 
That's all for zooming . I hope it helpful to you . 

    Wednesday, 9 November 2011

    SimplexLinepress - blogger version of Linepress template

    SimplexLinepress - template for newsportal
    Some readers asked me for a blogger version of Linepress template (from Gabfire) . After a long time ,now I want to show you the result . It's good for a magazine or news portal . Hope you all like this .


    Demo Download

    Install Instruction

    1,Download the template .

    2,Open the template file in any word editor . I recommend Notepad ++ for easy in editing .

    3,To add social network account


    Find this code :
    <div id="submenu">
                     <ul class="subnav">
                         <li><a title="Subscribe to latest posts in RSS" rel="nofollow" href="/feeds/posts/default" class="gab_rss" target="_blank">RSS for Entries</a></li>
                         <li><a title="Subscribe to latest posts via email" rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=simplex" class="gab_email" target="_blank">Subscribe via E-mail</a></li>                                               
                         <li><a title="follow on twitter" rel="nofollow" href="http://www.twitter.com/dinhquanghuy" class="gab_twitter" target="_blank">Follow on Twitter</a></li>                                               
                         <li><a title="Connect on facebook" rel="nofollow" href="http://www.facebook.com/simplexdesignblog" class="gab_facebook" target="_blank">Connect on Facebook</a></li>

    and change the link in bold to your social network and feed burner accounts .

    4,Save template and upload to blogger .

    5,Go to page elements .



    6,To add logo

    click on logo widget


    and add your logo into widget content as structure

    <img src="your logo url"/>

    like picture bellow


    7,To add item to main menu navigation


    click on 'menunav' widget


    add link to your categories



    8,To add content in 'teaser' section



    click on teaser widget



    add the category name into widget content


    Do the same for 'teaser','featureright','mediabar','primarybottomleft' widget

    9,To add content in the tab


    click on each widgets from 'priBottab1','priBottab2','priBottab3','priBotab4'


    add the category name into widget content ,add the name of category into widget title.


    10,Other widgets can be edit as you want . You can add script into widget content (ads ,video embed ...)

    11,You can add or remove or move widgets in anyplace as you want .

    Save changes . That's all for this template .

    I hope this template work fine for you .

    Sunday, 23 October 2011

    Create post summary for video post

    video post summary
    Some readers asked me how to make a frontpage like simplextube2 . The video player is shown directly in homepage . The idea behind this script is similar to other 'readmore' script ,but it focus on video .

    First , we set the form for a video post :
    video link ...
    endofvid
    [starttext]
    text for description
    [endtext]
    it means when we have a video post ,we have to post it as exact as this form .For example with a video from youtube :
    http://youtube.com/..... endofvid
    [starttext]
    this is description
    [endtext]
    The term 'endofvid' is used to marked the end of video link  ,the text in front of this term is video link .

    Second ,when creating readmore ,the script will scan all post content ,searching for the term 'endofvid' ,extract the text before this term and determine which service it is belonged . For example ,if the text contain the word ' youtube' ,it means video service provider is youtube . If the text contain 'vimeo' ,it means the video provider is vimeo .

    Third , create a video player for the video service we determine above . For example ,if the video link above is belong to youtube ,in this step ,we create a youtube player . After creating video player ,feed the video link to player ,and show it in front page .

    Fourth ,delete marked words 'endofvid' ,'[starttext]' ,'[endtext]

    Now we move to the script

    Insert this code before <body> 

    <script type='text/javascript'>
      <!--//--><![CDATA[//><!--
    var thumbnail_mode = 'float' ;
     summary_noimg = 50;
     summary_img = 50;
     img_thumb_height = 120;
     img_thumb_width = 192;

    function stripHtmlTags(s,max){return s.replace(/&lt;.*?&gt;/ig, '').split(/\s+/).slice(0,max-1).join(' ')}


    function createVideo(pID){
        var div = document.getElementById(pID);
        var postcontent = div.innerHTML;
       
        if (postcontent.indexOf("endofvid")!=-1) {
            var vidlink = postcontent.substring(0,postcontent.indexOf("endofvid"));
           
            if (/\.youtube\.com\/watch/i.test(vidlink))
            {               
            var vidid = vidlink.substring(vidlink.indexOf("http://www.youtube.com/watch?v=")+31)
            embedvid = '<object width="450" height="260"><param name="movie" value="http://www.youtube.com/v/'+ vidid + '&hl=en_US&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+ vidid + '&hl=en_US&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="450" height="260"></embed></object>'
            }
            else if (/\.liveleak\.com\/view/i.test(vidlink))
             {
             var vidid = vidlink.substring(vidlink.indexOf("http://www.liveleak.com/view?i=")+31)
            embedvid = '<object width="450" height="260"><param name="movie" value="http://www.liveleak.com/e/'+ vidid + '&hl=en_US&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.liveleak.com/e/'+ vidid + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="450" height="260"></embed></object>'     
            }
            else if (/vimeo\.com\/[0-9]+/i.test(vidlink))
            {
            var vidid = vidlink.substring(vidlink.indexOf("http://vimeo.com/")+17)
            embedvid = '<object width="450" height="260"><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+ vidid + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://vimeo.com/moogaloop.swf?clip_id='+ vidid + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="450" height="260"></embed></object>'
               }
            else if (/dailymotion\.com\/video/i.test(vidlink))
            {
            var vidid1= vidlink.split("_");
            var vidid= vidid1[0].substring(vidid1[0].indexOf("http://www.dailymotion.com/video/")+33)
            embedvid = '<object width="450" height="260"><param name="movie" value="http://www.dailymotion.com/swf/video/'+ vidid + '?width=&theme=none&foreground=%23F7FFFD&highlight=%23FFC300&background=%23171D1B&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.dailymotion.com/swf/video/'+ vidid + '?width=&theme=none&foreground=%23F7FFFD&highlight=%23FFC300&background=%23171D1B&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="450" height="260"></embed></object>'
            }
            else if (/metacafe\.com\/watch/i.test(vidlink))
            {       
            var vidid= vidlink.substring(vidlink.indexOf("http://www.metacafe.com/watch/")+30)
            embedvid = '<embed flashVars="playerVars=showStats=yes|autoPlay=no|" src="http://www.metacafe.com/fplayer/'+vidid+'.swf" width="450" height="260" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>'
            }       
            else
            {
            vidid="";
            embedvid="";
            }
           
         }
           
           
       
        postcontent = postcontent.replace (vidlink,"");
        postcontent = postcontent.replace("endofvid","");
        postcontent = postcontent.replace("[starttext]","");
        postcontent = postcontent.replace("[endtext]","");
       
        var embedvid1 = '<span class="notxt">'+embedvid+'</span>';
       
        var summary =  embedvid1 + postcontent;
        div.innerHTML = summary;
    }




    //--><!]]>

    </script>

    Content of this script is as exact as the explanation above ,step by step . In this script ,there are 5 video service : youtube ,liveleak,vimeo,dailymotion and metacafe . If you want another video service that allow video embedding ,feel free to suggest :D

    Now ,move to the body of the post ,find this code

    <data:post.body/>

    and replace it with
    <div expr:id='&quot;summary&quot; + data:post.id' style="margin-top:10px;">            
                                         <data:post.body/>
                                     </div>
                                     <script type='text/javascript'>createVideo(&quot;summary<data:post.id/>&quot;);</script>

    Now let's check for the post summary . You can create a post as the structure in step 1 ,insert a video from youtube ,and then see the result of post summary . Does the post show up with post summary and a video player ?

    Sunday, 16 October 2011

    Make an impressive landing page for blogspot .

    landing page
    Some readers asked me for making a static landing page for blogspot . It makes blog look more professional and separated to other blogspot’s blogs .

    In this post ,I will tell you how to make a landing page for blogspot . This post related to HTML,CSS ,Jquery and some Blogspot Api’s ,so you must be familiar to them before we start .

    The idea for this landing page is inspired by a design from Tympanus website .

    Live Demo

    Now let's start

    1,HTML markup


    The HTML structure consists of a main container and an unordered list where each item is one of the columns. The main container has class “ei_menu” and also the id “ei_menu”.
    Under the main container ,each of <li> item contains a link element with two spans inside and a div element with the content.
    The two spans are for the background image shown at the beginning and the image shown when click (active) . Since we are using just one image for each we will have to define the background position.
    Div element contain the title ,text,and links .

    <div id="ei_menu" class="ei_menu">
        <ul>
            <li>
                <a href="#" class="pos1">
                    <span class="ei_preview"></span>
                    <span class="ei_image"></span>
                </a>
                <div class="ei_descr">
                    <h2>title</h2>
    <a href="link">                <h3>Click here to go</h3></a>
                    <p>Some text here...</p>
                </div>
            </li>
            <li>
                <a href="#" class="pos2">
                    <span class="ei_preview"></span>
                    <span class="ei_image"></span>
                </a>
                <div class="ei_descr">
                    <h2>title</h2>
    <a href="link">                <h3>Click here to go</h3></a>
                    <p>Some text here...</p>
                </div>
            </li>
    <li>
                <a href="#" class="pos3">
                    <span class="ei_preview"></span>
                    <span class="ei_image"></span>
                </a>
                <div class="ei_descr">
                    <h2>title</h2>
    <a href="link">                <h3>Click here to go</h3></a>
                    <p>Some text here...</p>
                </div>
            </li>
    <li>
                <a href="#" class="pos4">
                    <span class="ei_preview"></span>
                    <span class="ei_image"></span>
                </a>
                <div class="ei_descr">
                    <h2>title</h2>
    <a href="link">                <h3>Click here to go</h3></a>
                    <p>Some text here...</p>
                </div>
            </li>
    <li>
                .....................
            </li>

        </ul>
    </div>

    Link in href attribute of this line  
    <a href="link"> <h3>Click here to go</h3></a>

    Can be link to any page you want . Link to all posts in blog is :
    http://blog_name.blogspot.com/search/posts/default
    When we use this HTML markup for home page ,it means we have to hide another elements . It's the time to use Blogspot API - the conditional statement .
    It look like this
    <b:if cond='data:blog.url == data:blog.homepageUrl'>
    The HTML markup
    <b:else/>
    Other elements you want to hide in home page
    </b:if>

    For example ,in default template (such as minima) ,we want to hide blog posts :

    <b:if cond='data:blog.url == data:blog.homepageUrl'>
    The HTML markup
    <b:else/>
    <b:section class='main' id='main1' showaddelement='no'>
    .......................
    </b:section>
    </b:if>

    2,The CSS

    Add this code in CSS sections of your template

    /* Menu style */
    .ei_menu{
    background:#111;
    width:100%;
    overflow:hidden;
    }
    .ei_menu ul{
    height:350px;
    margin-left:50px;
    position:relative;
    display:block;
    width:1300px;
    }
    .ei_menu ul li{
    float:left;
    width:75px;
    height:350px;
    position:relative;
    overflow:hidden;
    border-right:2px solid #111;
    }
    .ei_preview{
    width:75px;
    height:350px;
    cursor:pointer;
    position:absolute;
    top:0px;
    left:0px;
    background:transparent url(../images/bw.jpg) no-repeat top left;
    }
    .ei_image{
    position:absolute;
    left:75px;
    top:0px;
    width:75px;
    height:350px;
    opacity:0.2;
    background:transparent url(../images/color.jpg) no-repeat top left;
    }
    .pos1 span{
    background-position:0px 0px;
    }
    .pos2 span{
    background-position:-75px 0px;
    }
    .pos3 span{
    background-position:-152px 0px;
    }
    .pos4 span{
    background-position:-227px 0px;
    }
    .pos5 span{
    background-position:-302px 0px;
    }
    .pos6 span{
    background-position:-377px 0px;
    }
    .ei_descr{
    position:absolute;
    width:278px;
    height:310px;
    border-right:7px solid #f0f0f0;
    padding:20px;
    left:75px;
    top:0px;
    background:#fff;
    }
    .ei_descr h2{
    font-family: 'Rock Salt', arial, serif;
    font-size:26px;
    color:#333;
    padding:10px;
    text-shadow:0px 0px 1px #fff;
    background:#fff url(../images/stripe_light.gif) repeat top left;
    }
    .ei_descr h3{
    font-family: 'Raleway', arial, serif;
    color:#fff;
    text-shadow:0px 0px 1px #000;
    font-style:normal;
    padding:10px;
    background:#333;
    }
    .ei_descr p{
    color:#000;
    padding:10px 5px 0px 5px;
    line-height:18px;
    font-size:11px;
    font-family: Arial;
    text-transform:uppercase;
    }

    Meaning of these CSS tags can be found in CSS cheat sheets or websites focus on CSS . I will not explain here for keep the post short and clean .Replace the images in background attributes to yours own images .
    Add two lines

    <link href='http://fonts.googleapis.com/css?family=Rock+Salt' rel='stylesheet' type='text/css' />
    <link href='http://fonts.googleapis.com/css?family=Raleway:100' rel='stylesheet' type='text/css' />

    Right after </head> for embedding Google fonts into this design .

    3,The Javascript

    The idea is to expand the menu when clicking on it . The initial width for each menu item is 75 pixel ,when clicked ,the width is enlarged to 400 pixel (75pixel plus 325pixel for the hidden content )
    Add this code right before </body>

    &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
    $(function() {
    var $menu = $('#ei_menu &gt; ul'),
    $menuItems = $menu.children('li'),
    $menuItemsImgWrapper= $menuItems.children('a'),
    $menuItemsPreview = $menuItemsImgWrapper.children('.ei_preview'),
    totalMenuItems = $menuItems.length,

    ExpandingMenu = (function(){
    /*
    @current
    set it to the index of the element you want to be opened by default,
    or -1 if you want the menu to be closed initially
    */
    var current = -1,
    /*
    @anim
    if we want the default opened item to animate initialy set this to true
    */
    anim = true,
    /*
    checks if the current value is valid -
    between 0 and the number of items
    */
    validCurrent = function() {
    return (current &gt;= 0 &amp;&amp; current &lt; totalMenuItems);
    },
    init = function() {
    /* show default item if current is set to a valid index */
    if(validCurrent())
    configureMenu();

    initEventsHandler();
    },
    configureMenu = function() {
    /* get the item for the current */
    var $item = $menuItems.eq(current);
    /* if anim is true slide out the item */
    if(anim)
    slideOutItem($item, true, 900, 'easeInQuint');
    else{
    /* if not just show it */
    $item.css({width : '400px'})
    .find('.ei_image')
    .css({left:'0px', opacity:1});

    /* decrease the opacity of the others */
    $menuItems.not($item)
    .children('.ei_preview')
    .css({opacity:0.2});
    }
    },
    initEventsHandler = function() {
    /*
    when we click an item the following can happen:
    1) The item is already opened - close it!
    2) The item is closed - open it! (if another one is opened, close it!)
    */
    $menuItemsImgWrapper.bind('click.ExpandingMenu', function(e) {
    var $this = $(this).parent(),
    idx = $this.index();

    if(current === idx) {
    slideOutItem($menuItems.eq(current), false, 1500, 'easeOutQuint', true);
    current = -1;
    }
    else{
    if(validCurrent() &amp;&amp; current !== idx)
    slideOutItem($menuItems.eq(current), false, 250, 'jswing');

    current = idx;
    slideOutItem($this, true, 250, 'jswing');
    }
    return false;
    });
    },
    /* if you want to trigger the action to open a specific item */
    openItem = function(idx) {
    $menuItemsImgWrapper.eq(idx).click();
    },
    /*
    opens or closes an item
    note that &quot;mLeave&quot; is just true when all the items close,
    in which case we want that all of them get opacity 1 again.
    &quot;dir&quot; tells us if we are opening or closing an item (true | false)
    */
    slideOutItem = function($item, dir, speed, easing, mLeave) {
    var $ei_image = $item.find('.ei_image'),

    itemParam = (dir) ? {width : '400px'} : {width : '75px'},
    imageParam = (dir) ? {left : '0px'} : {left : '75px'};

    /*
    if opening, we animate the opacity of all the elements to 0.1.
    this is to give focus on the opened item..
    */
    if(dir)
    /*
    alternative:
    $menuItemsPreview.not($menuItemsPreview.eq(current))
    .stop()
    .animate({opacity:0.1}, 500);
    */
    $menuItemsPreview.stop()
    .animate({opacity:0.1}, 1000);
    else if(mLeave)
    $menuItemsPreview.stop()
    .animate({opacity:1}, 1500);

    /* the &lt;li&gt; expands or collapses */
    $item.stop().animate(itemParam, speed, easing);
    /* the image (color) slides in or out */
    $ei_image.stop().animate(imageParam, speed, easing, function() {
    /*
    if opening, we animate the opacity to 1,
    otherwise we reset it.
    */
    if(dir)
    $ei_image.animate({opacity:1}, 2000);
    else
    $ei_image.css('opacity', 0.2);
    });
    };

    return {
    init : init,
    openItem : openItem
    };
    })();

    /*
    call the init method of ExpandingMenu
    */
    ExpandingMenu.init();

    /*
    if later on you want to open / close a specific item you could do it like so:
    ExpandingMenu.openItem(3); // toggles item 3 (zero-based indexing)
    */
    });
    &lt;/script&gt;

    That’s all .
    There are two keypoints here :
    1-Make the HTML markup ,adding CSS and javascript to make an expanding menu for homepage .
    2-Hide elements which you do not want to show in homepage .

    I hope this post helpful to you .

    Saturday, 20 August 2011

    How to make a blogspot template : General steps of making blogspot template


    Blogger team tried to make their product easier to use and custom for all users with Template Design function. If you want small changes in fonts, background, layout..., this function can help. But if you want more to make your blog look like a professional website? It's time you need to learn structure of blogger template, APIs, javascripts ... to make a custom template. This serie: “How to make a Blogger template” will take you step by step to creating your own. I will try to make it short, simple and easy to understand, hope it helpful for you .
    ----------------------------------------------------------------------

    Chapter 1  Blogger Template Structure

    Chapter 2  Template Header

    Chapter 3  Template body and API's

    Chapter 4  Inside widget - "Includable"

    Chapter 5  Blogger data tags 1

    Chapter 6  Blogger data tags 2

    Chapter 7  How Blogger widget work

    Chapter 8  General steps of making a Blogger template

    ----------------------------------------------------------------------

    CHAPTER 8:   GENERAL STEPS OF MAKING A BLOGGER TEMPLATE


    This is the last chapter of series 'How to make a blogspot template'. In this chapter, as a blogger user, I want to share my experience in making Simplex's templates: working order, tools, tips. I won't focus on HTML/CSS /Javascript because you can find documents on these issues easily. I do not tends to go further on Blogger template structures/sections/widgets/data tags/API, because they are mentioned in previous chapters.

    Unlike other platforms such as Wordpress or Joomla which a template comes with many files, blogger template is in one file xml only .
    As we know, Blogger template contain sections. Here is the order of these sections:

    • Header
    • Blogpost
    • Sidebar
    • Footer

    All we need to do when making a template:

    • Place sections and widgets in right order. Add/remove sections /widgets
    • Add HTML arround these sections, and use CSS to decorating them.
    • Add javascript/jquery for special effects, get the feeds and mashup homepage.

    1, Place sections and widgets in right order

    Blogspot is made up with sections, widgets... so you have to place them in right order, add more sections /widget for the function you want and remove unnecessary sections/widgets .
    For example, in Simplex Blognews template, I add more sections for page list ( in the top of page ), sections for advertising banner ...remove default sections and widgets in sidebar.
    I also use conditional statement <b:if> to hide sections/widget in some specific cases. For example ,we all know blogpost widget show the post list /single post (see chapter on blogpost widget here), but in the homepage, I don't want it to show up, so I use a conditional statement to cover all blogpost widget:

    <b:if cond='data:blog.url == data:blog.homepageUrl'>
    homepage content
    <b:else/>
    blogpost widget .....
    </b:if>

    In the code above, if the current page is homepage, it will show homepage content, if the current page is a category page or single post, it will call blogpost widget for processing content.
    Or if we want to hide all the blog content when go to a specific page, we can use a conditional statement like that:

    <b:if cond='data:blog.url == &quot;page url&quot;'>
    .....
    <b:else/>
    other content here
    </b:if>
    By add/remove widgets and place them in right order, we have the frame of a template.

    2, Add HTML and CSS around sections/widgets

    We have a template's frame with sections and widgets, now we need to add more HTML tags around and decorate these HTML tags with CSS to make it display as we want: images, text, fonts  ....You can do all in this step.
    Firebugs is the best tool for this work, you can find the post on how to use this tool here. It will reduce your time on working with CSS and HTML. You can use this tool to inspect elements on websites which has design you love and find out which HTML/CSS their designer used. CSS tags information and cheatsheet can be found in this post.
    To get some inspirations, you can go to template galleries, collections, or go to famous blogs on design. Sometimes, combining the elements which you love from different templates can give you an unique design.

    3, Add Javascripts/jquery

    Because blogger doesn't allow server side programing, Javascript/Jquery give us the solution for mashing up a homepage. By using Javascript to get feeds from categories in blog, split the feed into post titles, post summaries ...and then display them, we have a good homepage, as you see in Simplex' templates.
    Javascript/Jquery is also used to make special effects, for example, sliders, hover buttons, menu ...
    You can find out more post on using Jquery/Javascript in SimplexDesign blog.

    That's all steps I applied when making a template and it works for me. I can't tell you how to make a specific template, because it's very long and take times. I hope with series 'How to make a blogspot template' you can:

    • Understand the basic of a blogspot template, structure,what it contain.
    • Functions of sections /widgets,how they work. Meaning of data tags/Api and statements.
    • General steps to make a template,what we have to do ,what we have to search in google for making an elements ....

    By reading all 8 chapters,I hope every time you see the code of Simplex templates, you can understand what I did, and then make your own customization or apply in making your own template.
    It take time to search, read and then apply to make a template. It's not easy. But if you want, you can do it. Thanks for your time.

    Friday, 5 August 2011

    How to make a blogger template : how blogspot widget work?


    Blogger team tried to make their product easier to use and custom for all users with Template Design function. If you want small changes in fonts, background, layout..., this function can help. But if you want more to make your blog look like a professional website? It's time you need to learn structure of blogger template, APIs, javascripts ... to make a custom template. This serie: “How to make a Blogger template” will take you step by step to creating your own. I will try to make it short, simple and easy to understand, hope it helpful for you .
    ----------------------------------------------------------------------

    Chapter 1  Blogger Template Structure

    Chapter 2  Template Header

    Chapter 3  Template body and API's

    Chapter 4  Inside widget - "Includable"

    Chapter 5  Blogger data tags 1

    Chapter 6  Blogger data tags 2

    Chapter 7  How Blogger widget work

    Chapter 8  General steps of making a Blogger template

    ----------------------------------------------------------------------

    CHAPTER 7:   HOW BLOGGER WIDGET WORKS


    In this chapter, we will combine all things from previous chapters to one and see how a widget works.
    In a template, Blogpost widget starts with this line:

    <b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'>
    The id can be vary in different template, but type="Blog" is required
    In this widget, there are some 'includable's:

    • <b:includable id='main' var='top'>: main includable, this includable will take the main task for processing data and send the result to monitor.
    • <b:includable id='nextprev'>: this includable will add the link 'next page', 'prev pag' at the bottom of homepage ,archive page, and add the link 'next post','previous post' at the bottom of single post .
    • <b:includable id='mobile-nextprev'>: this includable do the same task to nextprev includable above, but this includable will work if you browse the blog in mobile .
    • <b:includable id='post' var='post'>: this includable will process the data of each post, it will show post title, post body, date .... if you are reading a single post ,and show post summary if you are in homepage or archive page
    • <b:includable id='mobile-index-post' var='post'>: like 'post' includable above ,but it work on mobile
    • <b:includable id='postQuickEdit' var='post'>: this includable will add an small pencil at the end of post ,that allow blog owner can edit the post easily ,click on this pencil ,blog owner will be redirected to post editing window ,don't need to back to dashboard ,and search for post which he want to edit from post list.
    • <b:includable id='shareButtons' var='post'>: this includable will show a list of share buttons at the end of post.
    • <b:includable id='comments' var='post'>: show all comments of each post.
    • <b:includable id='commentDeleteIcon' var='comment'>: add a recycle bin symbol next to the comment ,allow blog owner delete unwanted comment.
    • <b:includable id='comment-form' var='post'>: show the comment form bellow the post ,allow reader to write their comment.
    • <b:includable id='backlinks' var='post'>: show the backlinks to a post.
    • <b:includable id='backlinkDeleteIcon' var='backlink'>: show the recycle bin icon next t'o the backlink.
    • <b:includable id='feedLinks'> and <b:includable id='feedLinksBody' var='links'>:show the feed links to blog and to each post.
    • <b:includable id='status-message'>: show the status message, like this ' show all post under label xyz'.

    Blogpost work as diagram bellow

     

    1, Blogpost widget starts working.

    2, It starts a loop statement to loop through all posts.

    3, Check value of counting variable “i”. If “i” smaller than the number of posts, call “post” includable for showing post data (post title, post body ,author, labels...).

    4a,4b,4c, In the “post” includable, if current page is a single post, it calls other includables such as post edit icon, comment, comment form ... . If current page is homepage or an archive page, these includables will not be called.

    5, Go to the next post and back to the check point at step 3.

    6, In case of finish looping, back to the main includable.

    7, Call “next prev” includable (or feedlinks, backlinks...if necessary), add the link to next and previous post to the end of page.

    8, Finish.

    In these includables, beside data tags, we can add HTML, javascript to make it display as we want.