我在prestashop 1.5.6.2商店安装了创新菜单(超级菜单),当我试图创建一个新菜单时,在BO中,ajax加载并得到这个结果
{"configure":false,"view":null}
创建按钮调用此功能
function editMenu(idMenu)
{
show_innovativemenu_activity = true;
$.ajax({
data: {employee_id_lang : employee_id_lang, token : token, innovativemenu_action : 'editMenu', id_menu : idMenu},
success: function(msg){
msg = $.parseJSON(msg);
$("div.configure_menu").html(msg.configure);
if(parseInt(idMenu))
$("div.view_menu").html(msg.view);
else $("div.view_menu").html('');
}
});
}
电话就是这样:创建新菜单
ajax调用这个php函数
public function editMenu($id_menu = null, $ajax = true)
{
global $smarty;
if (is_numeric($id_menu) AND ((int)$id_menu) > 0)
$menu = new Innovative_Menu((int)$id_menu);
else $menu = new Innovative_Menu();
$text_column_title_font_style = $text_column_title_font_weight = $text_column_title_font_size = $text_column_title_font_family =
$text_block_font_size = $text_block_font_family = $text_block_font_weight = $text_block_font_style =
$text_menu_font_style = $text_menu_font_family = $text_menu_font_size = $text_menu_font_weight = $text_column_list_font_style_hover = $text_column_list_font_weight_hover = '';
foreach (Innovative_Menu::$all_column_title_font_size as $font)
$text_column_title_font_size .= '<option value="'.$font.'" '.($font == $menu->column_title_font_size ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_weight as $font)
$text_column_title_font_weight .= '<option value="'.$font.'" '.($font == $menu->column_title_font_weight ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_style as $font)
$text_column_title_font_style .= '<option value="'.$font.'" '.($font == $menu->column_title_font_style ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Font_Family::get(true) as $font)
$text_column_title_font_family .= '<option value="'.$font.'" '.($font == $menu->column_title_font_family ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_style as $font)
$text_column_list_font_style_hover .= '<option value="'.$font.'" '.($font == $menu->column_list_font_style_hover ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_weight as $font)
$text_column_list_font_weight_hover .= '<option value="'.$font.'" '.($font == $menu->column_list_font_weight_hover ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_size as $font)
$text_block_font_size .= '<option value="'.$font.'" '.($font == $menu->block_font_size ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_weight as $font)
$text_block_font_weight .= '<option value="'.$font.'" '.($font == $menu->block_font_weight ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_style as $font)
$text_block_font_style .= '<option value="'.$font.'" '.($font == $menu->block_font_style ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Font_Family::get(true) as $font)
$text_block_font_family .= '<option value="'.$font.'" '.($font == $menu->block_font_family ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_style as $font)
$text_menu_font_style .= '<option value="'.$font.'" '.($font == $menu->font_style ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Font_Family::get(true) as $font)
$text_menu_font_family .= '<option value="'.$font.'" '.($font == $menu->font_family ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_size as $font)
$text_menu_font_size .= '<option value="'.$font.'" '.($font == $menu->font_size ? 'selected' : '').'>'.$font.'</option>';
foreach (Innovative_Menu::$all_font_weight as $font)
$text_menu_font_weight .= '<option value="'.$font.'" '.($font == $menu->font_weight ? 'selected' : '').'>'.$font.'</option>';
$default_language = (int)(Configuration::get('PS_LANG_DEFAULT'));
$languages = Language::getLanguages();
$display_flags = $this->displayFlags($languages, $default_language, 'home_text', 'home_text', true);
$smarty->assign(array(
'edit_menu' => true,
'menu' => $menu,
'tabs_of_menu' => $this->getTabsOfMenu($menu->id),
'admin_img' => _PS_ADMIN_IMG_,
'text_block_font_style' => self::cleanHTML($text_block_font_style),
'text_block_font_family' => self::cleanHTML($text_block_font_family),
'text_block_font_weight' => self::cleanHTML($text_block_font_weight),
'text_block_font_size' => self::cleanHTML($text_block_font_size),
'text_menu_font_style' => self::cleanHTML($text_menu_font_style),
'text_menu_font_family' => self::cleanHTML($text_menu_font_family),
'text_menu_font_size' => self::cleanHTML($text_menu_font_size),
'text_menu_font_weight' => self::cleanHTML($text_menu_font_weight),
'text_column_title_font_weight' => self::cleanHTML($text_column_title_font_weight),
'text_column_title_font_weight' => self::cleanHTML($text_column_title_font_weight),
'text_column_title_font_style' => self::cleanHTML($text_column_title_font_style),
'text_column_title_font_size' => self::cleanHTML($text_column_title_font_size),
'text_column_title_font_family' => self::cleanHTML($text_column_title_font_family),
'text_column_list_font_style_hover' => self::cleanHTML($text_column_list_font_style_hover),
'text_column_list_font_weight_hover' => self::cleanHTML($text_column_list_font_weight_hover),
'display_flags' => $display_flags,
'default_language' => $default_language,
'languages' => $languages
));
$dir_tpl = dirname(__FILE__);
if ($ajax)
{
$output['configure'] = $this->display(__FILE__, 'edit_element.tpl');
$output['configure'] = $this->context->smarty->fetch($dir_tpl . '/tpl/edit_element.tpl');
$output['view'] = $this->viewMenu($menu->id);
}
else $output = $this->display(__FILE__, 'tpl/edit_element.tpl');
//$output['configure'] = $this->context->smarty->fetch($dir_tpl . '/tpl/edit_element.tpl');
return $output;
}
ajax param默认为true,我想为什么显示函数重新生成false,viewMenu返回null,视图菜单函数是:
public function viewMenu($id_menu)
{
if (!is_numeric($id_menu))
return;
$id_menu = (int)$id_menu;
$menu = new Innovative_menu($id_menu);
return '<fieldset>
<legend>'.$this->l('Preview :').' '.$menu->name.'</legend>'.$menu->view().'
</fieldset>';
}
Module.php中的显示功能如下:
public function display($file, $template, $cacheId = null, $compileId = null)
{
if (($overloaded = Module::_isTemplateOverloadedStatic(basename($file, '.php'), $template)) === null)
return Tools::displayError('No template found for module').' '.basename($file, '.php');
else
{
$this->smarty->assign(array(
'module_dir' => __PS_BASE_URI__.'modules/'.basename($file, '.php').'/',
'module_template_dir' => ($overloaded ? _THEME_DIR_ : __PS_BASE_URI__).'modules/'.basename($file, '.php').'/'
));
if ($cacheId !== null)
Tools::enableCache();
$result = $this->getCurrentSubTemplate($template, $cacheId, $compileId)->fetch();
if ($cacheId !== null)
Tools::restoreCacheSettings();
$this->resetCurrentSubTemplate($template, $cacheId, $compileId);
return $result;
}
它应该返回tpl edit_element但它返回false。 提前谢谢。