Posts

Showing posts from June, 2013

Facebook - Sharing with site image, title and description

Facebook crawls the page to decide how to display it. In order to specify the share to look according to your liking, you will have to add open graph tags . Below is the example: <meta property="og:image" content="URL OF IMAGE" /> <meta property="og:title" content="TITLE TO APPEAR" /> in the header of each page of your site. You can know about it from here: http://support.sharethis.com/customer/portal/articles/475079-share-properties-and-sharing-custom-information#Open_Graph_Tags Please remove the "st" properties from the span tag code, the span tag should look like - Hello User, <span class='st_facebook_large' ></span>

Javascript: Textarea should replace break on enter

Use this code to  get break as user enters in the textarea. Hope this helps! <html> <head> <title>Insert new lines dynamically</title> <script type = "text/javascript">  function fillTarg() {  var TARG = document.getElementById("newtext")  var AREA = document.getElementById("textarea")   TARG.innerHTML = AREA.value.replace(/\n/g,"<br>") // Replace break on user enters  TARG.innerHTML = AREA.value.replace(/\s/g,"&nbsp;")  // Replace space on user enters } </script> </head>   <body> <textarea style="width:450px; height:150px;" id="textarea"  onKeyUp="fillTarg()">Click on the button below to add some lines!</textarea> <br><br> <span id="newtext"> </span> </body> </html>

Javascript - Color box using URL or iframe

We have to use this script where the output will take from url, Javascript: ======== <script> function getParameterByName(url, name) {   name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");   var regexS = "[\\?&]"+name+"=([^&#]*)";   var regex = new RegExp( regexS );   var results = regex.exec(url);   if( results == null )     return "";   else     return decodeURIComponent(results[1].replace(/\+/g, " ")); } $(document).ready(function(){ $('.dialog-open').each(function() {    $(this).colorbox({      height: 600,      width: 800,      iframe: true,      href: "contact?id=" + getParameterByName($(this).attr("href"), "id")    }); }); </script> HTML ===== <a href='test.php?id=$id' class="dialog-open"> test </a>    Source: http://www.jacklmoore.com/colorbox/

PHP / Smarty Tricks - Avoid looping for more than one loop for select query

The best way is we can use " IN_ARRAY " method, Here is the basic sample i have given, {assign var = "exp" value = ","|explode:$catid}   {section name=k loop=$blogcat}    <option {if in_array($blogcat[k].CAT_ID, $exp)} selected="selected"  {/if}  value="  {$blogcat[k]. CAT_ID }"  >{$blogcat[k].CAT_NAME}    </option>                                                         {/section}

PHP - Mysql - Apostrophe issue

The best solutions is to use: mysql_real_escape_string() Eg: INSERT INTO <t.name> ("content") VALUES (mysql_real_escape_string("There's a dummy content here"));   If you still facing issue, the best way is to use,   addslashes(mysql_real_escape_string()) Eg: INSERT INTO <t.name> ("content") VALUES (addslashes(mysql_real_escape_string("There's a dummy content here")));  

Dreamweaver 8 - Serial number

WPD800-53539-13932-17521