Posts: 196
Threads: 16
Joined: Mar 2010
I need to list all the pages available in the plugin page I'm creating.
I was wondering if there is a method available that will return an array with all the pages?.
Thanks!
Posts: 972
Threads: 27
Joined: Aug 2009
menu_data(), maybe, otherwise I don’t think there is any function. Or you could check how pages.php lists all pages?
Posts: 196
Threads: 16
Joined: Mar 2010
I tried menu_data() and breaks the code. As you suggested I went to the pages.php and looked at how it lists the pages there. I ended up copying some code and turned it into a function:
Code:
function getPages()
{
$path = GSDATAPAGESPATH;
//display all pages
$filenames = getFiles($path);
$count="0";
$pagesArray = array();
if (count($filenames) != 0) {
foreach ($filenames as $file) {
if (isFile($file, $path, 'xml')) {
$data = getXML($path .$file);
$status = $data->menuStatus;
//$pagesArray[$count]['title'] = $data->title;
$pagesArray[$count]['title'] = html_entity_decode($data->title, ENT_QUOTES, 'UTF-8');
$pagesArray[$count]['parent'] = $data->parent;
$pagesArray[$count]['menuStatus'] = $data->menuStatus;
$pagesArray[$count]['private'] = $data->private;
if ($data->parent != '') {
$parentdata = getXML($path . $data->parent .'.xml');
$parentTitle = $parentdata->title;
$pagesArray[$count]['sort'] = $parentTitle .' '. $data->title;
} else {
$pagesArray[$count]['sort'] = $data->title;
}
$pagesArray[$count]['url'] = $data->url;
$pagesArray[$count]['date'] = $data->pubDate;
$parentTitle = '';
$count++;
}
}
}
return $pagesArray;
}
I think if you guys include this into a global/common functions, then It can be useful for other plugin developers.
Posts: 972
Threads: 27
Joined: Aug 2009
That’s pretty much the content of menu_data(), are there any errors that could give an indication of why menu_data() breaks your plugin? Maybe menu_data() is not accessible on the admin-pages and we should make it accessible…
Posts: 196
Threads: 16
Joined: Mar 2010
I Get Fatal error: Call to undefined function menu_data() in .....
Yeah it would be great if such a function could be available in the admin pages.. Not sure if I would want to call it menu_data(), I would think get_pages() or get_available_pages() more suitable.
Thanks for all your help!