【发布时间】:2011-12-06 21:46:19
【问题描述】:
我遇到了一个 PHP 错误,通过我在 Internet 上的所有搜索,我一直无法破解。
错误提示:
Error message
Notice: Undefined offset: 3 in include() (line 89 of /home/devced/public_html/site/sites/all/themes/cedncsu/page.tpl.php).
所以,看看我的代码,我目前有(实际使用在下面评论):
<?php
// Get Base URL
global $base_url;
// Get the Page's Parent Menu Item
$menuParent = menu_get_active_trail();
// Since it returns an array, make sure to target what you are looking for
// You should print_r what menu_get_active_trail() to see what else it gives you
$menuParent = $menuParent[1]['link_title'];
$menuParent = strtolower(str_replace( " ", "-", $menuParent));
$menuParent = preg_replace('/[^\w\d_ -]/si', '', $menuParent);
// Generate class specific for department page headers
$menuParentDepartment = menu_get_active_trail();
$menuParentDepartment = $menuParentDepartment[3]['link_title']; // This is where they say the error is
$menuParentDepartment = strtolower(str_replace( " ", "-", $menuParentDepartment));
$menuParentDepartment = preg_replace('/[^\w\d_ -]/si', '', $menuParentDepartment);
// Current Page space replace/lowercase
$currentTitle = strtolower(str_replace( " ", "-", $title));
$currentTitle = preg_replace('/[^\w\d_ -]/si', '', $currentTitle);
?>
我认为这是我所缺少的一般编码实践,但迄今为止一直被难住了。任何帮助将不胜感激。谢谢!
【问题讨论】: