Friday, March 25, 2011

Adjust div height according to image in it dynamically on image swap

<img class="orbt" onmouseover="MM_swapImage('full','','http://demo/demo.jpg',1);MM_setTextOfLayer('text','','&lt;div class=&quot;dress-text&quot;&gt;&lt;strong&gt;Malyse&lt;br /&gt;&lt;/strong&gt;&lt;p&gt;&lt;/em&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;');var theImg = document.getElementById('full');var thediv = document.getElementById('container1');thediv.style.pixelHeight=parseInt(theImg.height)+200;" src="http://demo/demo.png" alt="Malyse" width="81" height="81" />

Different Sidebar for wordpress pages

Often one needs different sidebars for different pages in wordpress. This can be implemented using the below mentioned code.The logic used here is that we get the post id and assign sidebar based on their id's.
<div id="sidebar">

<?php
global $id;
$post_id_current = get_post($id,ARRAY_A);
$post_parent = $post_id_current['post_parent'];
if($post_parent!='')
{
$my_id=$post_parent;
}
else
{
$my_id=$id;
}

if($my_id!==4 )
{
 if ( !function_exists('dynamic_sidebar')

|| !dynamic_sidebar('sidebar2') ) : endif;

}
else
{
 if ( !function_exists('dynamic_sidebar')

|| !dynamic_sidebar('sidebar1') ) :  endif;
}
?>
</div>