Jump to content

Problems with parentheses in selector?


YYHMedia
 Share

Recommended Posts

I have a few multi-site instances that are talking to each other through a list of conditions primarily.  A few of these conditions (full list here) have parentheses in them such as "Rheumatoid Arthritis (RA)".  The code below should be pulling in the article that is found on the corresponding page on my blog - https://blog.yinyanghouse.com/relationships/conditions/rheumatoid-arthritis-ra

When I try to match these between the sites in a selector I get nothing back.  I've tried sanitizing it such as:

	foreach ($page->category_relationships_conditions as $crc) {
		$query = $sanitizer->selectorValue($crc->title);
			$myBlogsStart = $bl->pages->find("template=page-blog, category_relationships_conditions=$query, sort=title");
				foreach ($myBlogsStart as $mbs) {
					if (!in_array($mbs,$myBlogs)) { $myBlogs[] = $mbs;}
				}
	}

 

Every other selector except these few works perfectly.  How can I get those to match correctly?

Link to comment
Share on other sites

		$query = strtr($crc->title, array('(' => '', ')' => ''));

Changing the query line in my first post and "self sanitizing" with the command above works - but I'd still like to get an answer as I feel like this should be happening behind the scenes and there must be something I'm doing wrong within processwire to run into this....  

 

Link to comment
Share on other sites

Not sure about the selector sanitizing, but assuming category_relationships_conditions is a Page Reference field it seems like you could simplify things and avoid the issue at the same time by using the page object in the selector:

foreach($page->category_relationships_conditions as $crc) {
	$myBlogsStart = $bl->pages->find("template=page-blog, category_relationships_conditions=$crc, sort=title");
	// ...

 

Link to comment
Share on other sites

3 hours ago, YYHMedia said:

Thanks for the response and, yes, that would work if it wasn't a multi site setup, but in this case they objects wouldn't match.

Right you are, I overlooked that part of your post.

Taking another look at it I think the issue is that you need to specify the subfield of the page you are wanting to match against. Assuming it's the title it would be:

$myBlogsStart = $bl->pages->find("template=page-blog, category_relationships_conditions.title=$query, sort=title");

 

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...