hellomoto Posted October 26 Share Posted October 26 (edited) https://processwire.com/api/ref/selectors/ Is it not possible to access the `string` property? `$selectors->count` works, and $selectors->getArray() works for items. How is the string accessed? I've tried ->getProperty('string'), and I don't remember what else... The class has a selectorStr property but it's protected? Edited October 26 by hellomoto Link to comment Share on other sites More sharing options...
hellomoto Posted October 26 Author Share Posted October 26 Sorry, it's $selectors->__toString() Link to comment Share on other sites More sharing options...
TomPich Posted October 27 Share Posted October 27 In the Selectors class definition, Ryan wrote that the protected property "selectorStr" there only for debugging. I tried with $selectors->get("selectorStr") and it doesn’t work neither. So if I really need that string (and couldn’t store it earlier in the process), I would create a class that extends Selectors an allow selectorStr exposure... Link to comment Share on other sites More sharing options...
hellomoto Posted October 29 Author Share Posted October 29 On 10/27/2024 at 11:04 AM, TomPich said: In the Selectors class definition, Ryan wrote that the protected property "selectorStr" there only for debugging. I tried with $selectors->get("selectorStr") and it doesn’t work neither. So if I really need that string (and couldn’t store it earlier in the process), I would create a class that extends Selectors an allow selectorStr exposure... Okay thanks but why not just access via ->__toString()? Link to comment Share on other sites More sharing options...
TomPich Posted October 29 Share Posted October 29 You are right... 😊 Actually, _toString() is not supposed be called explicitly. It’s called when you do "echo $selectors". So when you do "echo $selectors", you get the string you want. But it’s not returned, it’s just displayed. Maybe you can do ob_start() and ob_get_clean() to capture the string you want in a variable. 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