Jump to content

Search for a combination of values in the multiselect page reference field


kalimati
 Share

Recommended Posts

I have a template for courses for a website on training.  Within the template I use a multiselect page reference field to define attributes associated with the course. While rendering the page I want search for a combination of attributes -in the multiselect page reference field - presence and absence of some of them -- and perform an operation accordingly. How do I search for a combination of values in the multiselect page reference field? Thanks.

Here is the pseudo code:

if ($page->pageReferenceField->has("title=one|two") && $page->pageReferenceField->doesnothave("title=three")) {
	echo ...;
}
	

 

Link to comment
Share on other sites

Finally I was able to solve it. dump command helped to nail the problem at each stage.

$classroom = $page->trgMode->find("title=In Classroom");
$online = $page->trgMode->find("title=Live Online Training");
$onsite = $page->trgMode->find("title=Onsite Training");
if (((count($classroom) == 0) && (count($online) == 0)) && (count($onsite) > 0)) {
	echo "<p>This course is available only as an Onsite program.</p>";
	}


 

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

×
×
  • Create New...