Please don't click on these links yet.

Under construction: ? * # 0-9 |A |B |C |D |E |F |G |H |I |J |K |L |M |N |O |P |Q |R |S |T |U |V |W |X |Y |Z

Your opinion is needed with a new "FAQ" I'm thinking of writing up. Click on this "FAQ link" now and leave a comment if you can spare the time.
Tutorials : How I made it toolbars paginations buttons widgets tweeks mega tweeks everything else inspiration ideas FAQ problems Fixing problems

How to add a Youtube video as a post comment on Blogger

Thursday, September 20, 2012  at 7:02 PM 6 comments
Have you ever wanted someone to be able to add a Youtube video to your own blog in response to a post you wrote about but don't know how to do it? Well now you can in three easy steps. Today I will show you how to do that.

There are a lot of tutorials out there already on how to do this but I found all of them do not display an actual Youtube video as a comment. I had to do a lot of digging around the Internet, and eventually I came across a post on how to do it but it was written in Burmese, on a blog in Mynmar. I can't read Burmese, so I opted to study that Burmese blog's "View Source" page, and I found the following lot of code in it. I added the code to one of my blogs and it worked the first time. Mind you I also had to figure out how to get the Youtube video to actually display because typing in [youtube=the-video-url-goes-here] simply did not work.

However, despite the fact this is a really easy tutorial and it works on newly created blogs, as well as most existing blogs, sometimes the code will not display a video on a blog that has a customised template. Why this happens I do not know. I am still trying to figure that out and trying to get the video comments to display on my other blog Birds of Tenterfield, NSW, Australia. It may have something to do with various scripts clashing or the template itself (of your blog) may have too much code in it. But generally this code will work on the very first attempt when you add it to your blog's template. If it doesn't, and you have followed the instructions below carefully, then you have a problem just like I do with my other blog.

LIVE-DEMO = This site has the code added to it, so if you'd like to test it out add a Youtube video in as a comment to this post. Please keep the video comments respectable and please don't add any graphic or advertising videos. Thanks!

INSTRUCTIONS:

STEP 1: Go to your "Edit Template" to start editing it and find the opening head tag <head>. Directly below it, on the next line, copy and paste in the following code:

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'/>
<SCRIPT src='http://code.jquery.com/jquery-latest.js' type='text/javascript'/>
<script type='text/javascript'>
//<![CDATA[
// Embed youtube videos in Blogspot comments by MS-potilas 2012.
// See http://www.ehlar.com/2012/03/blogger-comments-youtube-video.html //
// if oetag=0, just use video urls like:
// http://www.youtube.com/watch?v=12345678901
// surrounded by white space (video tag can be used, too)
// if oetag=1 (for nerdy blogs?), use syntax:
// [video=http://www.youtube.com/watch?v=12345678901]
// config:
var oetag = 0; // see above
var oetagname = "video"; // [video=zzz], maybe you like "embed" or "youtube" more?
var oelazy = -1; // -1 detect, 0 = normal, 1 = lazy (needs lazy load hack)
//
function oe_loadscript(filename) {
var scr=document.createElement('script');
scr.setAttribute("type","text/javascript");
scr.setAttribute("src",filename);
document.getElementsByTagName("head")[0].appendChild(scr);
}

function oe_jumptohash() { // reposition to anchor
window.scrollTo(0, $("#"+window.location.hash.replace(/^#/, "")).offset().top);
}

var oe_tid;
var oe_elems = {};
//
function oembed_callback(response) {
var resp = response;
revurl = resp.url.split("").reverse().join("");
html = oe_elems[response.callID].html();
ee = $(resp.html);
w = parseInt(ee.attr("width"));
h = parseInt(ee.attr("height"));
if(oelazy==1) { // convert to lazy load
src = ee.attr("src");
src += ((src.indexOf("?")==-1) ? "?" : "&") + "autoplay=1";
ee.attr("src", src);
ee.attr("style", "vertical-align:top;");
htm = $("<div/>").append(ee).html();
htm = $('<div/>').text(htm).html().replace(/"/g,'"');
resp.html = '<a href="'+resp.url+'" class="youtube-lazy-link" style="width: '+w+'px; height: '+h+'px; background: #000 url('+resp.thumbnail_url+') center center no-repeat;" onclick="$(this).replaceWith(\''+htm+'\');return false;"><div style="width:'+(w-4)+'px;height:'+(h-4)+'px;" class="youtube-lazy-link-div"></div><div class="youtube-lazy-link-info"><b>'+resp.title+(resp.playlist ? '</b> [playlist]' : '</b>')+'<br /><small>by '+resp.author_name+'</small></div></a>';
}

htmlx = html.replace("[" + oetagname + "="+resp.url+"]", " " + resp.url + " ");
htmlx = htmlx.replace("[" + oetagname + "="+resp.url+" ]", " " + resp.url + " ");
htmlx = htmlx.replace('"'+resp.url+'"', '"'+revurl+'"'); // trick to preserve href="url"
htmlx = htmlx.replace(resp.url, '<div style="height:'+h+'px;" class="oembed youtube">'+resp.html+'</div>')

htmlx = htmlx.replace('"'+revurl+'"', '"'+resp.url+'"'); // trick to preserve href="url"

if(html != htmlx) {

oe_elems[response.callID].html(htmlx);
if(window.location.hash.replace(/^#/, "").length > 0) {

if(oe_tid) window.clearTimeout(oe_tid);
oe_tid = window.setTimeout("oe_jumptohash()", 1000);
}

}

}

function oembed_yt(url, width, callID) {

src = "http://oembed-js.appspot.com/?url=" + encodeURIComponent(url) + "&callback=oembed_callback&callID=" + encodeURIComponent(callID);
if(width) src = src + "&maxwidth=" + width + "&maxheight=" + width;
oe_loadscript(src);
}

$(document).ready(function() {

det=$('<div class="youtube-lazy-link-div" />');
$("body").append(det);
if(det.css("position")=="absolute") {

if(oelazy != 0) oelazy=1;
}

else oelazy = 0;
det.remove();
window.setTimeout(function() {

var callID=0;
$(".comment-content,.comment-body,.comment-body-author").each(function() {

html = $(this).html();
if(oetag)
matches = html.match(new RegExp("\\["+oetagname+"=(https?:\\/\\/[^\\s<\\/]*youtu\\.*be[^\\]]+)", "g"));
else
matches = html.match(/([>\s^]|\[\w+=)(https?:\/\/[^\s<\/]*youtu\.*be[^\s<\]]+)/g);
if(matches && matches.length) {

for(var i=0;i<matches.length;i++) {

url = matches[i].match(/https?:\/\/[^\s<\/]*youtu\.*be[^\s<\]]+/);
oe_elems[callID] = $(this);
oembed_yt(url, $(this).width(), callID++);
}

}

});
}, 500);
});
//]]>
</script>

Then click on "Save Template".

STEP 2: If you want to add the instructions for adding a Youtube video to your comments section, so visitors can see it all the time, then do the following:

On the same page (Edit HTML) click on the "Expand Widget Template" option box. Hit the "Ctrl" and then the "F" key on your keyboard and paste in this code in the search bar that pops up.

<b:includable id='comment-form' var='post'>
Scroll down a bit and locate:

<p><data:blogCommentMessage/></p>

Directly below that line of code copy and paste in this text below:

To add a Youtube video as a comment type in or copy and paste the code below and replace the video url text with the one you want to add as a comment.<br/>
[video=ADD-ENTIRE-VIDEO-URL-THAT-YOU-VIEW-ON-THE-WATCH-PAGE-ON-YOUTUBE-HERE]<br/>

STEP 3: Then in the search bar copy and paste in this line of code below in order to find it, if applicable:

<b:includable id='threaded-comment-form' var='post'>

Repeat STEP 2 to add the instructions below the <p><data:blogCommentMessage/></p>.

Save your template and you are done.

FOOTNOTE: If, when searching for <p><data:blogCommentMessage/></p> and you see two instances of them within each section along with two instances of an iframe embedded comment form, place the instructions (text) below the second instance of <p><data:blogCommentMessage/></p>.

Changing a widget's background colour the quickest and easiest way ever!

Monday, September 10, 2012  at 3:31 PM 1 comment
Live demo of this is the "Talking Avatar" widget on this blog in the left hand column.

From time to time we all have widget's that we want to add a background colour to and we don't want to spend even 5 minutes doing it. So much time is wasted editing one's template to add this or that to it that after a while even you will get sick of changing the way your blog looks because it takes up too much of your time. Or worse, a whole lot of code is needed to get the same effect as we want just for one widget.

This tutorial takes you less time to apply the code than it does to read the above first paragraph. Your main delay will be deciding what colour you want the background colour to be for a particular widget.

Instructions:
Click on the "Edit" link or spanner icon and open up a widget to edit it. This will only work on the widgets that actually display content within that edit section. On a new line above all the code for the widget's content copy and paste in:

<div style="background: black; padding: 5px;">

At the very bottom of the widget content's code copy and paste in:

</div>

Change the background colour "black" to whatever colour you want. You can change "black" to "#ff1199", for example, to display hex colour codes. You do not necessarily have to type in a word for the colour.

If the padding for your widgets is already perfect then delete this bit of code:

padding: 5px;

Once you have typed in the colour you want the background to be select "save".

You are done! Couldn't be easier if you tried.

How I made the expandable/collapsible side column widgets

  at 12:48 PM 0 comments
At the time I was making a new template called "Aliens, UFOs and Videos". I was trying to make a template design that had a collapsible and expandable sidebar widget header3 that would hide the widget content or display it when clicked on the header3 title, just like the website I was trying to reproduce as a blogger template design. In order to solve certain problems, that problem being how to collapse and expand widgets by clicking on the header3 title, I doubted my own ability. I searched the internet to find a clue on how to achieve this. I looked and looked. I found a few tutorials but none of them worked for me. Eventually I came across a tutorial that was for a simple widget toggle with css and jQuery. The original code can be found here : http://www.sohtanaka.com/web-design/easy-toggle-jquery-tutorial/

The original codes that I worked from are:


The css code:
h2.trigger { padding: 0 0 0 50px; margin: 0 0 5px 0; background: url(h2_trigger_a.gif) no-repeat; height: 46px; line-height: 46px; width: 450px; font-size: 2em; font-weight: normal; float: left; } h2.trigger a { color: #fff; text-decoration: none; display: block; } h2.trigger a:hover { color: #ccc; } h2.active {background-position: left bottom;} /*--When toggle is triggered, it will shift the image to the bottom to show its "opened" state--*/ .toggle_container { margin: 0 0 5px; padding: 0; border-top: 1px solid #d6d6d6; background: #f0f0f0 url(toggle_block_stretch.gif) repeat-y left top; overflow: hidden; font-size: 1.2em; width: 500px; clear: both; } .toggle_container .block { padding: 20px; /*--Padding of Container--*/ background: url(toggle_block_btm.gif) no-repeat left bottom; /*--Bottom rounded corners--*/ }

The html code:
<h2 class="trigger"><a href="#">Toggle Header</a></h2> <div class="toggle_container"> <div class="block"> <h3>Content Header</h3> <!--Content--> </div> </div>

and The jQuery code:
$(document).ready(function(){ //Hide (Collapse) the toggle containers on load $(".toggle_container").hide(); //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state) $("h2.trigger").click(function(){ $(this).toggleClass("active").next().slideToggle("slow"); return false; //Prevent the browser jump to the link anchor }); });

As displayed on that website tutorial .... The code above consists of html, css, and jQuery codes to make it all work. However,there was no instructions on where to place the code in the .xml template file. In as little as 4 hours I figured out where to place all the code and got it all to work. At first the whole thing would not display properly, so I had to cheat a bit. I visited the live demo here (http://www.sohtanaka.com/web-design/examples/toggle/), right clicked on the page and selected "View source". Sure enough, the live demo had all the missing code so I copied and pasted it all over again into my template. I deleted the <h1></h1> code as I didn't need that. Once I saved the template, I found it worked as it was supposed to work. However, when I viewed my blog I clicked on the header title, to make the widget expand and collapse but the entire page jumped to the top of the page. I needed the toggle function to stop jumping. After another search on the Internet I found a line of code that fixed the problem.

Now, to achieve the impossible. With the basic function of three collapsible and expandable widgets on the blog, I now needed to create a way to add widgets to it. I wanted to add the "Add a gadet" function to the original code. After many practise attempts at trying to alter the code, and failing, an idea hit me. What if I add an entire div section between the codes?
 
<div class="container">
<h2 class="trigger"><a href="#">Web Design &amp; Development</a></h2>
<div class="toggle_container">
<div class="block">
<h3>Need a Website?</h3>
<img src="thumbnail.gif" alt="" />
<p>Consequat te olim letalis premo ad hos olim odio olim indoles ut venio iusto. Euismod, sagaciter diam neque antehabeo blandit, jumentum transverbero luptatum. Lenis vel diam praemitto molior facilisi facilisi suscipere abico, ludus, at. Wisi suscipere nisl ad capto comis esse, autem genitus. Feugiat immitto ullamcorper hos luptatum gilvus eum. Delenit patria nunc os pneum acsi nulla magna singularis proprius autem exerci accumsan. </p>
<p>Praesent duis vel similis usitas camur, nostrud eros opes verto epulae feugiat ad. Suscipit modo magna letalis amet et tego accumsan facilisi, meus. Vindico luptatum blandit ulciscor mos caecus praesent sed meus velit si quis lobortis praemitto, uxor. </p>
</div>
</div>
<h2 class="trigger"><a href="#">Logo / Corporate Identity</a></h2>
<div class="toggle_container">
<div class="block">
<h3>Need a Logo?</h3>
<img src="thumbnail.gif" alt="" />
<p>Consequat te olim letalis premo ad hos olim odio olim indoles ut venio iusto. Euismod, sagaciter diam neque antehabeo blandit, jumentum transverbero luptatum. Lenis vel diam praemitto molior facilisi facilisi suscipere abico, ludus, at. Wisi suscipere nisl ad capto comis esse, autem genitus. Feugiat immitto ullamcorper hos luptatum gilvus eum. Delenit patria nunc os pneum acsi nulla magna singularis proprius autem exerci accumsan. </p>
<p>Praesent duis vel similis usitas camur, nostrud eros opes verto epulae feugiat ad. Suscipit modo magna letalis amet et tego accumsan facilisi, meus. Vindico luptatum blandit ulciscor mos caecus praesent sed meus velit si quis lobortis praemitto, uxor. </p>
</div>
</div>
<h2 class="trigger"><a href="#">Seach Engine Optimization</a></h2>
<div class="toggle_container">
<div class="block">
<h3>Need to be Heard?</h3>
<img src="thumbnail.gif" alt="" />
<p>Consequat te olim letalis premo ad hos olim odio olim indoles ut venio iusto. Euismod, sagaciter diam neque antehabeo blandit, jumentum transverbero luptatum. Lenis vel diam praemitto molior facilisi facilisi suscipere abico, ludus, at. Wisi suscipere nisl ad capto comis esse, autem genitus. Feugiat immitto ullamcorper hos luptatum gilvus eum. Delenit patria nunc os pneum acsi nulla magna singularis proprius autem exerci accumsan. </p>
<p>Praesent duis vel similis usitas camur, nostrud eros opes verto epulae feugiat ad. Suscipit modo magna letalis amet et tego accumsan facilisi, meus. Vindico luptatum blandit ulciscor mos caecus praesent sed meus velit si quis lobortis praemitto, uxor. </p>
</div>
</div>
<h2 class="trigger"><a href="#">eCommerce</a></h2>
<div class="toggle_container">
<div class="block">
<h3>Have Product to Sell?</h3>
<img src="thumbnail.gif" alt="" />
<p>Consequat te olim letalis premo ad hos olim odio olim indoles ut venio iusto. Euismod, sagaciter diam neque antehabeo blandit, jumentum transverbero luptatum. Lenis vel diam praemitto molior facilisi facilisi suscipere abico, ludus, at. Wisi suscipere nisl ad capto comis esse, autem genitus. Feugiat immitto ullamcorper hos luptatum gilvus eum. Delenit patria nunc os pneum acsi nulla magna singularis proprius autem exerci accumsan. </p>
<p>Praesent duis vel similis usitas camur, nostrud eros opes verto epulae feugiat ad. Suscipit modo magna letalis amet et tego accumsan facilisi, meus. Vindico luptatum blandit ulciscor mos caecus praesent sed meus velit si quis lobortis praemitto, uxor. </p>
</div>
</div>
<p style="text-align: center; font-size: 1.1em;"><a href="http://www.sohtanaka.com/web-design/easy-toggle-jquery-tutorial/">Tutorial</a> by <strong>Soh Tanaka</strong>. Check out his <a href="http://www.sohtanaka.com/web-design-blog/">Web Design Blog</a> for more tutorials!</p>
</div>



Above is the code which I copied and pasted from the live demo page (in the View source section). I stripped the code down to it's basic code thus removing the actual contents of the widgets. Below is what I ended up with:


 <div class='container'>
<h2 class='trigger'><a href='#'>Web Design &amp; Development</a></h2>
<div class='toggle_container'>
<div class='block'>
<h3>Need a Website?</h3>
Add content here.
</div></div>
<h2 class='trigger'><a href='#'>Logo / Corporate Identity</a></h2>
<div class='toggle_container'>
<div class='block'>
<h3>Need a Logo?</h3>
Add content here.
</div></div>
<h2 class='trigger'><a href='#'>Seach Engine Optimization</a></h2>
<div class='toggle_container'>
<div class='block'>
<h3>Need to be Heard?</h3>
Add content here.
</div></div>
<h2 class='trigger'><a href='#'>eCommerce</a></h2>
<div class='toggle_container'>
<div class='block'>
<h3>Have Product to Sell?</h3>
Add content here.
</div> </div>
<p style='text-align: center; font-size: 1.1em;'><a href='http://www.sohtanaka.com/web-design/easy-toggle-jquery-tutorial/'>Tutorial</a> by <strong>Soh Tanaka</strong>. Check out his <a href='http://www.sohtanaka.com/web-design-blog/'>Web Design Blog</a> for more tutorials!</p>
</div>


 
I then proceeded to add the same lot of code into the left column sidebar. A few other problems arose after adding this code to the template. I noticed that when I viewed the "Design" page these expandable/collapsible widgets were in the fully expanded mode. They could not be collapsed at all. This made it impossible to move existing widgets in the footer up into the sidebar, or moving widgets from the sidebar down into the footer area. After much thought I came up with an idea. That idea was to strip the code down to remove all the contents and then somehow add an existing widget to it. Eventually I ended up with the code below (This is just for one of the widgets in the entire container).
 
 
<div class='container'>
<h2 class='trigger'><a href='#'>+ / -&#160;&#160;&#160;Seach Engine Optimization</a></h2>
<div class='toggle_container'>
<div class='block'><b:section class='sidebar' id='sidebartab01' preferred='yes' showaddelement='yes'>
<b:widget id='HTML24' locked='false' title='Get Bookmarklet' type='HTML'/>
</b:section>
</div></div>

</div>
 
The code in blue bold is what I added to the code that created not only the "Add a gadget" feature but it shrunk the entire container down so it was in a collapsed mode. I saved the template, and viewed my blog, and I suddenly became excited. This feature has so much potential. I found I could now add widgets to the "Add a gadget" section in the design page. I could also move widgets about and everything worked fine.

It works in Internet Explorer, Google Chrome and Firefox web browsers.

A tutorial will be written up on how to add this feature to your blog. There are 6 of these widgets on this "Blogger Tutorials for everyone" blog, in the right hand column - at the top.

Scrollbox codes

<a target='_blank' title='DON'T TOUCH MY PHONE' href='ADDYOURURLHERE'><img src='https://lh4.googleusercontent.com/-qSyLJ0X94nk/T-_ekHbo_mI/AAAAAAAAHmY/qk0v-X5s32s/s320/58298-dont-touch-my-phone.png' border='0'/></a>

This free script provided by
JavaScript Kit

FAQ

YOUR OPINION COUNTS! A list of topics that I am thinking of writing about but need feedback from visitors before I go ahead with it.

Click to view more Pages
 

This site consists of tutorials that you would not normally see elsewhere. I am adding tutorials that I have either tweeked or created myself, using existing code already found on the Internet.

Back To Top Image by Cool Text: Logo and Button Generator - Create Your Own Logo

Scroll to Bottom Back to Top