Hmm still getting class not found errors. Even if I add a simple Yii import at the top of the file Menu.php like this
<?php
Yii::import('zii.widgets.CPortlet');
class Menu
{
function updateMenuOrder()
{
foreach ($_GET['listItem'] as $position => $item)
{
$menu = Menu::model()->findByPk($item);
$menu->position = $position;
$menu->save(false);
}
}
}
?>
I still get
PHP Fatal error: Class ‘Yii’ not found in C:\xampp\htdocs\sitemanager\protected\administrator\components\Menu.php on line 3
To generalize the problem, I’m using the jquery ui sortable component thats javascript update function gets called every time a user moves an item on the page
$("#menu-list").sortable({
handle : '.handle',
update : function () {
var order = $('#menu-list').sortable('serialize');
$.post("/sitemanager/protected/administrator/components/Menu.php?"+order);
}
});
The javascript update handler uses the jquery ‘post’ function as shown to send data to a php file. This php file then needs to update the database with the information sent. I’m having trouble writing the backend php file in that the file doesn’t seem to recognize any Yii classes or commands.
Is this possible with Yii? Or is there a better way to do this.