Developing from a .NET Perspective

Blogger Conditional Tags - reposted





Blogger Conditional Tags for different page types

Conditional template tags in Blogger template allows you to specify a part of your template code on specific types of pages or specific URLs.
One practical application could be to display a widget on specific pages. You can hide sidebar on some pages, apply a meta tag to certain page or whatsoever. Complex Blogger templates make large use of these conditional tags. In this post, I'll show you the possible conditional tags and their example usage.

Blogger Conditional Tags for different page types - Ultimate Blogger Guide
A conditional template tag in Blogger looks like following
<b:if cond='condition_expression'>
    <!-- content when condition is satisfied -->
</b:if>

List of Conditional tags for page types

Archive page

<b:if cond='data:blog.pageType == "archive"'>
<!--archive_Page-->
</b:if>

Error Page (404)

<b:if cond='data:blog.pageType == "error_page"'>
<!-- all error pages-->
</b:if>

Index Page

<b:if cond='data:blog.pageType == "index"'>
<!-- all index pages -->
</b:if>

Homepage

<b:if cond='data:blog.url == data:blog.homepageUrl'> 
<!-- only homepage -->
</b:if>

Item (post) pages

<b:if cond='data:blog.pageType == "item"'>
<!-- all item pages -->
</b:if>

Specific Post by URL

<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "2014/08/foo.html"'> 
<!-- a item page from august 2014 with post-title 'foo'-->
</b:if>

Label page

<b:if cond='data:blog.searchLabel'>
<!-- all label pages -->
</b:if>

Specific Label Page

<b:if cond='data:blog.searchLabel == "foo"'>
<!-- for label 'foo' -->
</b:if>

Search page

<b:if cond='data:blog.searchQuery'>
<!-- all search pages -->
</b:if>

Specific Search Query page

<b:if cond='data:blog.searchQuery == "foo"'>
<!-- for query 'foo' -->
</b:if>

Static page

<b:if cond='data:blog.pageType == "static_page"'>
<!-- all static pages -->
</b:if>

Specific Static page by URL

<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/foo.html"'> 
<!-- a specific static page with name 'foo' -->
</b:if>

AND/OR/NOT

AND
<b:if cond='data:blog.pageType == "index"'>
  <b:if cond='data:blog.searchQuery'>
    <!--search_page AND index_page-->
  </b:if>
</b:if>
OR
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/foo.html"'> 
  <!-- static_site foo OR static_site bar -->
      <b:else/>
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/bar.htm"'> 
  <!-- static_site foo OR static_site bar -->
   </b:if>
</b:if>
NOT
<b:if cond='data:blog.pageType != "item"'>
  <!-- all pages except item pages -->
</b:if>

<b:if cond='data:blog.url != data:blog.homepageUrl'> 
  <!-- all pages but NOT homepage -->
</b:if>

How to Use conditional tags

To apply a conditional tag to some content, simply put the content inside the opening <b:if cond…> and the closing </b:if> like:
<b:if cond='data:blog.pageType == "item"'>
    # THIS CONTENT WILL BE EXECUTED IF CONDITION IS TRUE
</b:if>
In the example above, the content will only appear on post pages.
The content can be a div, a section, a style tag or another conditional tag etc.
If you want to specify a alternate content (when the condition is false), you need to insert a <b:else/> tag followed by the content, like this:
<b:if cond='data:blog.pageType == "item"'>
    # THIS CONTENT WILL BE EXECUTED IF CONDITION IS TRUE
    # i.e. if current page is post (item) page
<b:else/>
    # THIS CONTENT WILL BE EXECUTED IF CONDITION IS FALSE
    # i.e. if not post page
</b:if>
The <b:else/> also works like an OR operator as explained above.

Example Applications

  • Display widgets on specific pages
  • Applying different styling to static pages
  • Adding FB meta tags and Twitter Card tags
  • Load JS on specific pages
  • Optimize Blog Title for SEO

Blogger Conditional Tag Wrapper Tool

Use this tool in order simplify wrapping conditional tags. All you have to do is copy paste the code into the field provided. Then choose the condition and click "Wrap" button. It's that simple. No more hunting down for Blogger conditionals!
If you need to encode your code, for example, in order to embed AdSense code in template, use "Encode & Wrap" button.
If you have any queries or feedback, do have your say in comments.


Share:

David Oberhoffer Chief Investigator at Private Eyes

 

David Oberhoffer
Chief Investigator at Private Eyes
Pleasant Hill, California, United States500+ connections

Chief Investigator
Private Eyes Investigative and Protective services
Law Enforcement Consultant
Oberhoffer and Associates
Law-Enforcement Expert Consultant
Forensic Photographer
Security Site Survey Inspections and Planning / Research
Document Recovery and Research
Crime Scene and Forensic Sciences
Educational Improvement and Training
Back Ground Investigations
Management and Supervisory issues.
SFMOMA San Francisco Museum of Modern Art
SFMOMA San Francisco Museum of Modern Art
Director of Security ( Interim)
Director of Security (Interim)
Under the Deputy Director of Administration and Finance, my responsibilities included:
· Managing the operations within the Security and Emergency Services Department at the Museum and its associated properties
· Supervisor of the contract security services provider
· Co-author of the Museum’s Emergency Response Plan, Evacuation Plans, Floor Warden Plan, and Training Policy Manuals for the security personnel
· Developed training curriculum for the Museum’s security personnel and provide in-house training
· Review budgets for the Department and oversee the guards’ schedules
· Primarily responsible for the Museum’s Disaster Preparedness Program, including coordination with San Francisco Police and Fire Department.
· Managing the security systems that include security cameras, access control devices and alarm warning systems
· Represented the Security Department at all Museum EventsAssistant Director of Security
For the San Francisco Museum of Modern Art, as the Assistant Director of Security , this position entails responsibilities for directing, coordinating and overseeing all activities of the onsite Security staff, including all supervisory, training and operational functions at SF MOMA, in accordance with post orders and client instructions, and following all internal procedures.
Additionally, the Assistant Director helps write security policies, meets and confers with employee representatives, helps plan for special events activities, and coordinates Museum Emergency Services responses.
Professor - Administration of Justice Education
Diablo Valley College
I also have taught in the highly regarded " College for Kids" program which brings High School Students to Diablo Valley College to prepare them for a college level education.
Instructor - Criminal Justice Education
Carrington College of California
In this dual position, I was tasked with instructing students enrolled in this degree-granting program that included:
Investigative Techniques, Evidence and Property recovery / handling, Forensic and Crime-Scene procedures, Report Writing, Terrorism, Organized Crime, Constitutional Law, Career Development and other subjects.
Chief of Police
City of McFarland
Federal Inspector: Aviation,Surface Transporation and Site Security
US Department of Homeland Security / TSA
Lieutenant of Police
Government
Other responsibilities included:

Experience

Assistant Director of Security

  •  - Present3 years 11 months

    San Francisco Basy Area and all of the Western United States

    I have 30+ years of Law Enforcement experience including numerous plain-clothes detective duties, assignments to the Special Investigations Division as a Police Inspector, Commanding Officer: CSI Unit, ID/Records, and Special Events planning teams. I am a Court recognized Expert Witness status in Police Proceduers and Investigative methodology. I retired as a Chief of Police, and as a Federal Inspector with strong training in Safety and Security facilities reviews. I also have 30 years of…

  •  - Present13 years 7 months

    San Francisco Bay Area, and in the San Diego Region

    Serving the Legal and Private Sector Communities in the fields of:

  • 1 year 6 months

    •  - 9 months

      San Francisco California

      San Francisco Museum of Modern Art

    •  - 10 months

      San Francisco

      San Francisco Museum of Modern Art

  •  - 1 year

    Pleasant Hill Main Campuis

    As a Faculty member of the Administration of Justice Education Department I currently instruct DVC Students in Crime Scene Investigations techniques and procedures in both the classroom and laboratory venues.

  •  - 2 years 7 months

    Carrington College-San Francisco Bay Area

    As the Director of Criminal Justice Education and Lead Instructor, I researched, designed and presented all the related classes in this department, as well as being responsible for managing the day to day activities of all students and other staff members.

  •  - 10 months

    McFarland California

    Served as the chief executive officer in a newly formed police department, following the removal of the Kern County sheriff’s sub-station, where I had been contracted to design, develop, implement the foundations of a basic law enforcement agency. Also served as Director of Emergency Services and (briefly) as Interim City Manager.

  •  - 2 years 1 month

    San Francisco Bay Area

    Assignments as a Transportation Security Inspector for the TSA stationed at the San Francisco International Airport (SFO) included both surface and cargo posts. Responsibilities included investigating any and all violations of federal regulations that impacted aviation-related activities in and around the airport and environs and surface transportation-related activities in and around the airport and surrounding counties. Trained in , and performed numerous Security Site Surveys throughout the Bay Area.

  •  - 27 years

    San Francisco Police Department

    During my assignment as a Police Lieutenant to the City of San Francisco, I gained internal experience with responsibilities as a staff officer, crime scene investigator and photographer, community liaison officer, governmental (police) liaison officer, budget analyst, and patrol assignment officer. My duties also required me to function as a subject-matter expert in computer systems, records management, and crime scene investigations.

     Platoon Commander: Potrero, Richmond, and Taraval Districts
     Record Management Section: Unit-OIC 2nd Watch
     Crime Scene Investigation: Unit Commanding Officer
     Court Expert Status: police procedures (California Superior Courts)
     Court Expert Status: interrogations and interviewing (Federal Courts)
     Official Lead Departmental Liaison Officer for all visiting Police Officials
     Team Leader for Crisis Intervention Response Teams ( CIRT)
     Neighborhood Emergency Response Team ( NERT) Officer-in-Charge ( District Level)
     City-Wide NERT/Disaster Planning Committee Member


Share:

Advertisement

The H-1b visa created an insidious process rife with abusive actors.





Popular Posts

Blog Archive

Ad Home

More Links

Follow Us

No one has ever become poor by giving, Please Donate

Flickr Images

Blogger news

Powered by Blogger.

Comments

Facebook

Search This Blog

Find Us On Facebook

Random Posts

Recent Posts

Header Ads

BlogRoll

Labels

Popular Posts

Recent Posts

Unordered List

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  • Aliquam tincidunt mauris eu risus.
  • Vestibulum auctor dapibus neque.

Theme Support

Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.