यह पोस्ट हाल ही में अपडेट की गयी है : December 7th, 2020
Aaj hum janenge ki Blogger me conditional tags ki madad se widgets gadgets ko hide show kaise kare? Jab hum blogger me template customization karte hai tab bahut sari problems face karni padti hai.
Jaise ki kisi widget/gadget/sidebar/script/ ko specific page pe dikhana hai ya fir form ko sirf contact us page pe hi dikhana hai aur other pages se hide karna hai.
Example 1. Jab visitor hamare about us page pe land karta hai to sidebar show nahi honi chahiye aur jab visitor post/article pe click kare to sidebar wapas se dikhai deni chahiye.
Example 2. Kisi widget jaise ki labels ko mobile devices me se hide aur destop me show karna hai.
Iske liye hum conditional tags ka use karke blogger me asani se kisi specific parts ko hide aur show kar sakte hai.
Waise to isme bahut tarah ki conditions hoti hai par is post me hum hide/show conditional tags ke bare me janenge.
Conditional tags ko blogger html template me apply kiya jata hai aur yeh kuch is tarah opening <b:if cond….. and closing </b:if> tag hote hai.
Conditional tag example:
<b:if cond='your condition'>YAHAN AAP KA HTML CODE</b:if>
Also read: CDN kya hai aur blogger me free CloudFlare CDN ka use karke website speed kaise badhaye?
Agar isi ko css code apply na karke conditional tag ka use kare to iske html codes browser me load hi nahi honge jisse site ki speed increase hogi.
<b:widget id='ContactForm2' locked='false' title='Agar koi sawal, sujhav hai to is contact form ko fill karke send kare!' type='ContactForm' version='1' visible='true'> <b:includable id='main'> <b:if cond='data:blog.url!=data:blog.homepageUrl'> <b:if cond='data:title != ""'> <h2 class='title'><data:title/></h2> </b:if> <div class='contact-form-widget'> <div class='form'> <form name='contact-form'> <p/> <data:contactFormNameMsg/> <br/> <input class='contact-form-name' expr:id='data:widget.instanceId + "_contact-form-name"' name='name' size='30' type='text' value=''/> <p/> <data:contactFormEmailMsg/> <span style='font-weight: bolder;'>*</span> <br/> <input class='contact-form-email' expr:id='data:widget.instanceId + "_contact-form-email"' name='email' size='30' type='text' value=''/> <p/> <data:contactFormMessageMsg/> <span style='font-weight: bolder;'>*</span> <br/> <textarea class='contact-form-email-message' cols='25' expr:id='data:widget.instanceId + "_contact-form-email-message"' name='email-message' rows='5'/> <p/> <input class='contact-form-button contact-form-button-submit' expr:id='data:widget.instanceId + "_contact-form-submit"' expr:value='data:contactFormSendMsg' type='button'/> <p/> <div style='text-align: center; max-width: 222px; width: 100%'> <p class='contact-form-error-message' expr:id='data:widget.instanceId + "_contact-form-error-message"'/> <p class='contact-form-success-message' expr:id='data:widget.instanceId + "_contact-form-success-message"'/> </div> </form> </div> </div> </b:if></b:includable> </b:widget>
Aap dekh sakte hai is code me maine red txts ko highlight kiya hai jo ki conditional tag hai.
Step 4. Conditional tag successfully apply karne ke bad template ko save karde aur site load karke results dekhe.
Aapko ise apne widget me <b:includable id=’main’> ke bad conditional tag lagana hai aur </b:includable> se pahle </b:if> lagana hai, ab apka widget is condition ko follow karega.
Conditional tags comparison operator pe behave karte hai jaise ki ==(is equal to) aur !=(is not equal to)
Isme (==) ki jagah (!=) lagane pe yeh reverse ho jata hai, matlab ki (==) se widget show hoga (!=) se widget hide hoga.
Niche kuch conditional tags hai jise aap jarurat ke anusar copy karke apne blog me use kar sakte hai.
<b:if cond='data:blog.isMobileRequest == "true"'> YAHAN AAP KA HTML CODE </b:if>
<b:if cond='data:blog.isMobileRequest == "false"'> YAHAN AAP KA HTML CODE </b:if>
<b:if cond='data:blog.pageType == "index"'> YAHAN AAP KA HTML CODE </b:if>
<b:if cond='data:blog.pageType == "item"'> YAHAN AAP KA HTML CODE </b:if>
<b:if cond='data:blog.pageType == "static_page"'> YAHAN AAP KA HTML CODE </b:if>
<b:if cond='data:blog.url == "URL of the page"'> YAHAN AAP KA HTML CODE </b:if>
<b:if cond='data:blog.pageType == "error_page"'> YAHAN AAP KA HTML CODE </b:if>
Blogger widget ko post aur static page pe show karne ke liye:
<b:if cond='data:blog.url == data:post.url'> YAHAN AAP KA HTML CODE </b:if>
<b:if cond='data:blog.pageType == "archive"'> YAHAN AAP KA HTML CODE </b:if>
<b:if cond='data:blog.url == data:blog.homepageUrl'> YAHAN AAP KA HTML CODE </b:if>
Jaise ki maine pahle btaya tha ki agar aap in conditional tags me == ki jagah != replace karke widgets ko hide karne me use kar sakte hai.
Example
Widget show karne ke liye:
<b:if cond='data:blog.url == data:blog.homepageUrl'> YAHAN AAP KA HTML CODE </b:if>
<b:if cond='data:blog.url != data:blog.homepageUrl'> YAHAN AAP KA HTML CODE </b:if>
Ye conditional tags aapke blog ka design, speed, SEO improve karne me helpful sabit honge jisse aapke blog ka look professional lagega jo ki ek successful blogger ki pahchan hai.
Ummid hai ki ye jankari aapke bahut kaam aayegi agar koi presani hai to niche comments me jarur bataye. Agar aap iske bare me jyada jankari rakhte hai to please hamare aur readers ke sath jarur share kare.
Ye bhi padhe:
AAPKE JAISI WEBSITE KO DESIGN KARNE KE LIYE HAME KYA KAR NA HOGA.PLZ TELL ME
Sandeep ji sabse pahle to thank you apko ye website design pasand aayi. Iske liye apko badhiya template apke blog me install karna hai. Ye template maine $21 me themeforet se purchase kiya hai. Agar aap new purchae nahi karna chahte hai to aap sora template & gooyabi template se badhiya template download kar sakte hai wo bhi free. Uar puri settings ke liye humne tutorial banaye hai unko padhe agar iske bad samjh nahi aaye to aap hum se puch sakte hai.