我使用Joomla 2.5建立一箇中型網站,我決定通過自動創建菜單來減輕維護和內容管理的難題。如何找出Joomla JTable列/字段名稱?
我查找了擴展名,但是隻找到了Joomla 1.5擴展名。我最終嘗試升級名爲Auto Menu Magic的GPL擴展。
很容易處理基本問題,如擴展文件中的XML標籤,因爲Joomla中有一個頁面可以幫助您從Joomla 1.5遷移到1.6。
我提到的擴展名有一個名爲onContentAfterSave的函數,它在保存文章時由joomla調用。我一直在通過在管理界面中創建垃圾文章進行調試,並將代碼更改爲在幾個地方拋出異常,我可以在管理前端看到這些錯誤消息。
這是我卡住了:
$db = &JFactory::getDBO();
$menu = JTable::getInstance('menu');
$menu->menutype = $menutype;
$menu->name = $name;
$menu->link = $link;
$menu->type = $linktype;
$menu->published = $published;
$menu->componentid = $componentid;
$menu->parent = $menuparentid;
$menu->sublevel = $menusublevel;
$menu->checked_out = 0;
$menu->checked_out_time = 0;
$menu->pollid = 0;
$menu->browserNav = 0;
$menu->access = 0;
$menu->utaccess = 0;
$menu->lft = 0;
$menu->rgt = 0;
$menu->home = 0;
$menu->params = $params;
// Figure out the order (Just pop this article at the end of the list):
$menu->ordering = $menu->getNextOrder(
"menutype = ".$db->Quote($menu->menutype).
" AND published >= 0 AND parent = ".(int) $menu->parent
);
// Validate:
if (!$menu->check())
return NULL;
// DEBUG 2 -- Integrity check
throw new Exception ("menutype: $menutype, name: $name, link: $link published: $published, componentid: $componentid menuparentid: $menuparentid menusublevel: $menusublevel");
// Save:
if (!$menu->store())
return NULL;
// DEBUG 1
throw new Exception(" Could save! ");
正如你可以在上面看到,我試圖把當菜單被保存到數據庫異常(DEBUG 1)。這個例外從來沒有達到,但是達到了上面的例外(DEBUG 2)。這意味着$ menu-> check()返回true,但不是$ menu-> store()。我假設數據庫正在返回一個錯誤,因爲一些Joomla數據庫結構可能在1.5之後發生了變化。
我已經讀了很多這些過去幾小時的來源,但我找不到一件事。我如何查看Joomla表所使用的列,以便我可以正確調試此錯誤?
在此先感謝!
PS:我也看過SQL數據庫,但它沒有多大幫助。這些變量似乎與列名稱有不同的命名約定。
太棒了!堆棧跟蹤和錯誤細節,最後! –