“No utilities registered for `I_Display_Type_Controller`” on nextgen gallery ajax call wordpress

I’m trying to load a nextgen Gallery via ajax, but I getting this error instead

I tried a lot of thing and this is the closer I get

Read More
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;
}

this returns as response

<h1>Exception thrown</h1><p>No utilities registered for `I_Display_Type_Controller`</p>

the ajax works, tried with wp_queries, and a bunch of stuff, all works, all but nextgen gallery related stuff

I think this is the piece of code reporting the error

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;
    }

What more can I try?

EDIT–
I tried to look up on these method calls and changed this file
wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_gallery_display/module.nextgen_gallery_display.php
looking for !is_admin() changed for true (for test) and the error changed to:

<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>

I tried to specify the template: echo nggShowGallery($galeria, 'coberturas', 8); but nothing changed

it seems that it is related to the fact that wordpress ajax api makes admin calls https://wordpress.stackexchange.com/questions/53309/why-might-a-plugins-do-shortcode-not-work-in-an-ajax-request

there is a way to change this?

Related posts

1 comment

  1. this answer made it possible to me:
    https://wordpress.stackexchange.com/questions/96026/nextgen-gallery-how-to-get-picture-url-by-gallery-id

    I changed the ajax return to a template part using SMK theme view, the ajax action became:

    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();
    }
    

    with smk you can send variables through get_template_part function

    On galeria-principal.php I have

    <?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 ?>
    
    <...>
    

    This will work correctly with ajax

Comments are closed.