首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“没有为`I_Display_Type_Controller`注册实用程序”在nextgen图库ajax上调用wordpress

“没有为`I_Display_Type_Controller`注册实用程序”在nextgen图库ajax上调用wordpress
EN

Stack Overflow用户
提问于 2015-05-28 23:37:52
回答 1查看 3.2K关注 0票数 2

我试图通过ajax加载nextgen Gallery,但是我得到了这个错误

我试了很多方法,现在离我更近了

代码语言:javascript
复制
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;
}

这将作为响应返回

代码语言:javascript
复制
<h1>Exception thrown</h1><p>No utilities registered for `I_Display_Type_Controller`</p>

ajax起作用了,用wp_queries试过了,还有一堆东西,都起作用了,除了nextgen画廊相关的东西

我认为这是一段报告错误的代码

代码语言:javascript
复制
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;
    }

我还能尝试什么呢?

编辑--我试图查找这些方法调用,并将此文件更改为wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_gallery_display/module.nextgen_gallery_display.php,查找!is_admin(),更改为真(用于测试),错误更改为:

代码语言:javascript
复制
<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进行管理调用https://wordpress.stackexchange.com/questions/53309/why-might-a-plugins-do-shortcode-not-work-in-an-ajax-request有关

有办法改变这一点吗?

EN

回答 1

Stack Overflow用户

发布于 2015-05-29 05:42:12

这个答案使我能够做到:https://wordpress.stackexchange.com/questions/96026/nextgen-gallery-how-to-get-picture-url-by-gallery-id

我使用SMK theme view将ajax返回更改为模板部件,ajax操作变为:

代码语言:javascript
复制
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上,我有

代码语言:javascript
复制
<?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中正常工作

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30511142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档