Thursday, September 22, 2011

How to show different images in different page using single block

step1:write the block title

step2:write the following php code in body
<?
global $base_url;//give the base url path link "http://www.fando.in"
$url =  $_SERVER['REQUEST_URI'];//it return the  argument of url like "http://www.fando.in/photo" then this while return "photo"
switch($url){
case '/photo':
$img="<img alt='' src = '{$base_url}/sites/default/files/about-us-image.jpg' />";
print $img;
break;
case '/image' :
$img="<img alt='' src = '{$base_url}/sites/default/files/IDW_In_63_0.jpg' />";
print $img;
break;
}
?>
step3:select the "php code " input format.
step4:Show block on specific pages,in that user need to write where this block display
eg:photo
step5:select the region,for proper display block.
eg:leftside,rightside etc

Tuesday, September 20, 2011

target "_blank" opens two windows (Means link open in New window as well as same window)

step1)suppose you add html code in a page of drupal using FCK EDITOR , In that one facebook link is there and after clicking that link,that link open in new window as well as same window.
Here is the code :
<a target="_blank" href="http://www.facebook.com/pages/The-Ideal-School-of-Manhattan/156013431088499">facebook</a>
step2:This problem occurs from "Google Analytic" module

step3:To solve this problem U have three ways:

 1st way->upgrade google analytic module to google_analytics 6.x-3.x-dev(here is link  http://drupal.org/node/807234 )
2nd way->disabled "Track outbound links" in google analytic module(In Site configuration -> google analytic)
3rd way ->Add this patch to the "googleanalytics.js" file
// Track all external links as page views after URL cleanup.
             // Currently required, if click should be tracked as goal.
             _gaq.push(["_trackPageview", '/outbound/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--')]);
+            if(this.target == '_blank'){
+                return true;
+            }
+            else{
             setTimeout('document.location = "' + this.href + '"', 100);
           }
+          }
           else {
             // External link clicked.
             _gaq.push(["_trackEvent", "Outbound links", "Click", this.href]);
@@ -51,10 +56,15 @@
             // that a user can click on the outbound link before the tracking code loads,
             // in which case the event will not be recorded.
             // See http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55527
+            if(this.target == '_blank'){
+                return true;
+            }
+            else{
             setTimeout('document.location = "' + this.href + '"', 100);
           }
         }
       }
+      }
     });
   });
 });
 
MORE REFERENCE VISIT BELOW LINK
        http://drupal.org/node/1057688