我正在尝试通过ajax加载nextgen图库,但我收到此错误
我尝试了很多东西,这就是我越接近
function noix_galeria_click() {
// check nonce
$nonce = $_POST['nextNonce'];
if ( ! wp_verify_nonce( $nonce, 'myajax-next-nonce' ) )
die ( 'Busted!');
$cobertura = get_post_meta($_POST['postId'], 'id_da_galeria', true);;
echo nggShowGallery($galeria);
exit;
}
这将作为回复
返回<h1>Exception thrown</h1><p>No utilities registered for `I_Display_Type_Controller`</p>
ajax工作,尝试使用wp_queries,以及一堆东西,所有工作,除了nextgen画廊相关的东西
我认为这是报告错误的代码段
function _retrieve_utility_class($interface, $context='all')
{
$class = FALSE;
if (!$context) $context = 'all';
if (isset($this->_utilities[$interface])) {
if (isset($this->_utilities[$interface][$context])) {
$class = $this->_utilities[$interface][$context];
}
// No utility defined for the specified interface
else {
if ($context == 'all') $context = 'default';
$class = $this->_retrieve_utility_class($interface, FALSE);
if (!$class)
throw new Exception("No utility registered for `{$interface}` with the `{$context}` context.");
}
}
else throw new Exception("No utilities registered for `{$interface}`");
return $class;
}
我还可以尝试什么?
EDIT--
我试着查看这些方法调用并更改了这个文件
可湿性粉剂内容/插件/ NextGen的画廊/产品/ photocrati_nextgen /模块/ nextgen_gallery_display / module.nextgen_gallery_display.php
寻找!is_admin()
更改为true(测试)并将错误更改为:
<h1>Default Gallery Type Template</h1>
<p>
This is the default gallery type template, located in:<br/>
<b>/home/ian/Sites/portalsabores/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_gallery_display/templates/index.php</b>.
</p>
<p>
我尝试指定模板:echo nggShowGallery($galeria, 'coberturas', 8);
但没有改变
似乎与wordpress ajax api进行管理员调用[{3}}
的事实有关有办法改变这个吗?
答案 0 :(得分:0)
我使用SMK theme view将ajax返回更改为模板部分,ajax操作变为:
function noix_galeria_click() {
// check nonce
$nonce = $_POST['nextNonce'];
if ( ! wp_verify_nonce( $nonce, 'myajax-next-nonce' ) )
die ( 'Busted!');
$cobertura = get_post_meta($_POST['postId'], 'id_da_galeria', true);
ob_start();
?>
<?php smk_get_template_part('parts/coberturas/galeria-principal.php', array(
'galeria' => $cobertura,
'post_id' => $_POST['postId']
)); ?>
<?php
$output = ob_get_contents();
ob_end_clean();
echo $output;
die();
}
使用smk,您可以通过get_template_part函数发送变量
在galeria-principal.php
我有
<?php
global $nggdb;
$gall_ids = $nggdb->get_ids_from_gallery($this->galeria); // smk allow you to return the variables as properties of $this
$images = $nggdb->find_images_in_list($gall_ids); // see these methods at
// wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/lib/ngg-db.php
// then build the template
$evento = get_post($this->post_id);
?>
<...>
<?php foreach ($images as $image): ?>
<?php
// I build this path because imageURL was empty, not sure why
$file_path = get_home_url() .$image->_ngiw->_cache['path'] . '/' . $image->_ngiw->_cache['filename'];
$file_desc = $image->_ngiw->_cache['description'];
?>
<li>
<img src="<?php echo $file_path ?>" alt="<?php echo $file_desc ?>">
</li>
<?php endforeach ?>
<...>
这将适用于ajax