Jump to content

Conditional statement IF OR


Peter Knight
 Share

Recommended Posts

Hi guys

I have something working and I'm not sure it's the most efficient API usage. 

I want to display some content if the page is Vets or any sub page below Vets.

My tree structure looks like this:

Home
Doctors
Vets (ID 1116)
 - Vets sub page 01
 - Vets sub page 02
 - Vets sub page 03
 - - Vets sub sub page 01
 - - Vets sub sub page 02
 - Vets sub page 04
Pilots
Gardeners

My working code is:

<?php

if  
	(
	$page->matches('id=1116') // Page is Vets Overview
	||   // OR
	$page->parent->matches('id=1116')  // Parent Page is Vets Overview
	)

	{
	echo "My conditional content";
	}

?>

Thanks
P

Link to comment
Share on other sites

I probably miss something and won't go through a selector for that purpose:

<?php

if  
	(
	($page->id == 1116) // Page is Vets Overview
	||   // OR
	($page->parent->id == 1116)  // Parent Page is Vets Overview
	)

	{
	echo "My conditional content";
	}

?>

Any reason to use the same template for the overview and its children?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...