Conditional tags

Blogger me conditional tags se widgets gadgets ko hide show kaise kare?

यह पोस्ट हाल ही में अपडेट की गयी है : June 10th, 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?

Conditional tags use karne ke fayde

Kuch log kahte hai ki blogger me kisi part ko hide karna ho to css code apply karke hide kar sakte hai, jaise ki contact form ko home page se hide karna hai to simple css code .widget.ContactForm {display: none;} laga ke hide kar denge.
Is condition me form hide to ho gaya par iske html codes browser me load hote rahenge, sirf hume yeh contact form dikhai nahi dega.

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.

Conditional tags kaise use kare?

Blogger me conditional tags use karna kuch jyada hard kam nahi hai bas thoda sa dhyan dene ki jarurat hai fir bahut easy hai. Chaliye kuch steps me jante hai ki kitni asani se hum apne blog me ise use kar sakte hai.
Step 1. Sabse pahle apne blogger dashboard me template >> html pe click kare.
Step 2. Ab apko html codes dikhai denge inke bich kahin bhi cursor rakhe aur Keyboard me CTRL+F ki button press karke jis widget/code pe conditions apply karna chahte hai use find kare ya fir jump to widget ki list pe click karke find kar sakte hai.
Step 3. Code find karne ke bad hume codes kuch is tarah se dikhege. Ab aap isme red fonts me dekh sakte hai ki kis tarah se aur kahan conditional tag apply karna hai. Jaise ki maine is code me conditional tag ka use karke homepage se hide kiya hai.
<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 != &quot;&quot;'>
    <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 + &quot;_contact-form-name&quot;' 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 + &quot;_contact-form-email&quot;' 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 + &quot;_contact-form-email-message&quot;' name='email-message' rows='5'/>
        <p/>
        <input class='contact-form-button contact-form-button-submit' expr:id='data:widget.instanceId + &quot;_contact-form-submit&quot;' 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 + &quot;_contact-form-error-message&quot;'/>
          <p class='contact-form-success-message' expr:id='data:widget.instanceId + &quot;_contact-form-success-message&quot;'/>
        </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.

To show conditional tags

Blogger widget ko sirf mobile device me show karne ke liye:
<b:if cond='data:blog.isMobileRequest == "true"'>
YAHAN AAP KA HTML CODE
</b:if>
Blogger widget ko sirf desktop device me show karne ke liye:
<b:if cond='data:blog.isMobileRequest == "false"'>
YAHAN AAP KA HTML CODE
</b:if>
Blogger widget ko Index Pages: Homepage, Labels Page aur Archive Page pe show karne ke liye:
<b:if cond='data:blog.pageType == "index"'>
YAHAN AAP KA HTML CODE
</b:if>
Widget ko only post page pe show karne ke liye:
<b:if cond='data:blog.pageType == "item"'>
YAHAN AAP KA HTML CODE
</b:if>
Blogger widget ko single posts ya static page pe show karne ke liye:
<b:if cond='data:blog.pageType == "static_page"'>
YAHAN AAP KA HTML CODE
</b:if>
Blogger widget ko kisi single page pe show karne ke liye:
<b:if cond='data:blog.url == "URL of the page"'>
YAHAN AAP KA HTML CODE
</b:if>
Blogger widget ko 404 Error Pages pe show karne ke liye:
<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>
Widget ko Archive Pages pe show karne ke liye
<b:if cond='data:blog.pageType == "archive"'>
YAHAN AAP KA HTML CODE
</b:if>
Widget ko only home page pe show karne ke liye.
<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>
Replace with
Widget hide karne ke liye:
<b:if cond='data:blog.url != data:blog.homepageUrl'>
YAHAN AAP KA HTML CODE
</b:if>

Ye conditional tag 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:

2 Comments

  1. penduhelp.in June 25, 2016
  2. Abid Khan June 25, 2016

अपनी प्रतिक्रिया दें!

Do NOT follow this link or you will be banned from the site!