alexm Posted October 24, 2020 Share Posted October 24, 2020 I'm having a bit of a problem with a selector: pages()->get("template=blog-post,blog_categories.title=$page->title,sort=-publish_from,images>0"); The selector works for all pages however this page's title is Women's Team and the category page title is also Women's Team. If I change the selector to: pages()->get("template=blog-post,blog_categories.title=Women's Team,sort=-publish_from,images>0"); It works as expected. Is this expected with apostrophes? I thought apostrophes were acceptable in selector string queries? Thanks in advance. Link to comment Share on other sites More sharing options...
teppo Posted October 24, 2020 Share Posted October 24, 2020 Have you tried running the title through $sanitizer->selectorValue()? That's what you should be doing anyway, passing "raw" values to selectors is never a good idea — even if said value comes from a field on the page ? Link to comment Share on other sites More sharing options...
alexm Posted October 24, 2020 Author Share Posted October 24, 2020 Hey @teppo! Thanks for your input. Yeah, I've tried that also. No joy. Link to comment Share on other sites More sharing options...
teppo Posted October 24, 2020 Share Posted October 24, 2020 Right — seems like it's an issue with formatting, i.e. single quote gets escaped (converted to HTML entity). Try $sanitizer->selectorValue($page->getUnformatted('title')) instead, that should work. 1 2 Link to comment Share on other sites More sharing options...
alexm Posted October 24, 2020 Author Share Posted October 24, 2020 @teppo and that's done it!! Thank you. Weirdly when I tested the output of $page->getUnformatted('title') earlier with an echo I got no output, but now I am. Thank you again for your help, time, expertise and all. Being the weekend too! ? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now