cb2004 Posted August 3, 2020 Share Posted August 3, 2020 I need to get an array of IDs in the config.php files to workaround something. Is there any way to do this, I have tried wire('pages') but dont seem to be having much joy. Link to comment Share on other sites More sharing options...
Gideon So Posted August 3, 2020 Share Posted August 3, 2020 @cb2004, As usual, can you post us some code then we can try to give some suggestion. Gideon Link to comment Share on other sites More sharing options...
adrian Posted August 4, 2020 Share Posted August 4, 2020 You'll need to do it with raw SQL. Something like this: $pdo = new \PDO("mysql:host=$config->dbHost;dbname=$config->dbName", $config->dbUser, $config->dbPass); $stmt = $pdo->query('SELECT `id` FROM pages WHERE templates_id = "29"'); $rows = $stmt->fetchAll(\PDO::FETCH_NUM); 3 Link to comment Share on other sites More sharing options...
cb2004 Posted August 4, 2020 Author Share Posted August 4, 2020 6 hours ago, adrian said: You'll need to do it with raw SQL. Something like this: $pdo = new \PDO("mysql:host=$config->dbHost;dbname=$config->dbName", $config->dbUser, $config->dbPass); $stmt = $pdo->query('SELECT `id` FROM pages WHERE templates_id = "29"'); $rows = $stmt->fetchAll(\PDO::FETCH_NUM); Thanks so much for your reply Adrian. In the end I went with a solution in ready.php: $members = wire('pages')->get(1302)->children; $subMembers = array(); foreach($members as $m) $subMembers[] = $m->id; And in config.php: $config->usersPageIDs = array_merge($config->usersPageIDs, $subMembers); Seems to be working ok, but what route would be best/fastest? Link to comment Share on other sites More sharing options...
adrian Posted August 4, 2020 Share Posted August 4, 2020 @cb2004 - if that works, great - I didn't think it would work to set something in ready.php and use it in config.php PS - you can simplify the $subMembers bit to: $subMembers = wire('pages')->get(1302)->children->each('id'); or even better because it won't load the pages, just their IDs: $subMembers = wire('pages')->findIDs('parent=1302'); 3 Link to comment Share on other sites More sharing options...
bernhard Posted August 5, 2020 Share Posted August 5, 2020 Hahaha, read the post to the end before answering ? 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