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
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?
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:
with smk you can send variables through get_template_part function
On
galeria-principal.php
I haveThis will work correctly with ajax