Jump to content

Error with multiple page IDs in selector


Peter Knight
 Share

Recommended Posts

is it possible to call multiple page IDs in a selector?

I was trying to fetch a few specific pages by ID for a menu as follows

$formnav = $pages->get("1216,1217,1218"); // Get specific pages
echo $sideMenuForms->render($options, null, $formnav);

and it throws the following error

Fatal error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? field='1216', value='', selector: '1216,1217,1218' (in /var/www/vhosts/

 

It works if there is a single page ID specified but not multiples.

Looking up the API reference, there is a "get by ID method" for multiple page IDs but it does nothing and no error

$formnav = $pages->getById([1216,1217,1218]); // Get specific pages
echo $sideMenuForms->render($options, null, $formnav);

 

I can always revert back to a template or path based selector but was hoping to keep it based on ID for the moment.


 

 

Link to comment
Share on other sites

$pages->get("id=1216|1217|1218"); // returns a single page (first match)
$pages->getById([1216,1217,1218]) // returns a PageArray and is similar to
$pages->find("id=1216|1217|1218");

It should work if $sideMenuForms->render() function expects a PageArray as third argument and if the PageArray is not empty (check with $formnav->count)

 

 

Link to comment
Share on other sites

23 hours ago, kixe said:

$pages->get("id=1216|1217|1218"); // returns a single page (first match)
$pages->getById([1216,1217,1218]) // returns a PageArray and is similar to
$pages->find("id=1216|1217|1218");

 

Both 

$pages->find("id=1|2|3");

and 

$pages->getById([1216,1217,1218])

worked.

 

My original 

$formnav = $pages->getById([1216,1217,1218]); // Get specific pages

wasn't returning the correct pages because the menu options needed this removing

'show_root' => true,

Thanks everyone

 

 

  • Like 2
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...