I am using tinymce on a cms and I want to be able to have a dropdown menu of all pages on the site (stored in a db) to choose from when adding a link but all I am getting is an emtpy set of values.
I am using the Link plugin and have the following in my tinymce init:
tinymce.init({
selector: "textarea#description, textarea#answer",
menubar: false,
width: '58%',
height: 200,
plugins: ["link","paste"],
paste_as_text: true,
toolbar: "undo redo | bold | bullist numlist | link unlink",
link_list: "../inc/internal-links-list.php"
});
I am not sure if the url for the link list is correct (it is relative to the file that this code is in).
And in my php:
<?php
require_once("core.php");
$objPage = new Pages;
$pages = $objPage->get_all();
$urls = array();
foreach ($pages as $page) {
$urls[] = array('title' => $page['page'], 'value' => $page['url']);
}
return json_encode($urls);
// Also tried echo json_encode($urls);
// Below is something I have tried to remove the double quotes around the keys to see if that was the problem but no
//$array_final = json_encode($urls);
//$array_final = preg_replace('/"([a-zA-Z_]+[a-zA-Z0-9_]*)":/','$1:',$array_final);
//echo $array_final;
?>
When I inspect the dropdown element I basically see a lot of empty divs, like so:
<div id="mce_137" class="mce-menu-item mce-stack-layout-item" tabindex="-1" role="menuitem"><i class="mce-ico mce-i-none"></i> <span id="mce_137-text" class="mce-text"></span></div>
<i class="mce-ico mce-i-none"></i>
<span id="mce_137-text" class="mce-text"></span>
</div>
Can anyone shed any light please?