Hi,
I have a view with an ajax pager, but it doesn't work when i embed the view within page.tpl.php.
The ajax isn't working and the views ajax related JS files aren't being included at head tag.
Here's my code:
$view = views_get_view('works_outros');
$view->set_display('block_1');
print $view->preview();
I had tried also with module_invoke (no ajax either):
$block = module_invoke('views', 'block', 'view', 'works_outros-block_1');
print $block['content'];
I learned that at page.tpl the header is already written, trough this post:
http://drupal.org/node/386388
But even if i manually add the scripts code at page.tpl the ajax pager isn't working and no error is given...
So i don't know where is the problem.
Can you help me?
thanks,
Carlos
Comments
Comment #1
dawehnerOkay this is critical :) Sure sure..
When you execute any kind of code in your page tpl.php js cannot work, because $scripts is already defined.
To fix it you could use hook_preprocess_page and put this code at the end:
Comment #2
carvalhar CreditAttribution: carvalhar commentedhi,
yeah i know, these 3 post talk about it:
http://drupal.org/node/337022
http://drupal.org/node/386388
http://drupal.org/node/823056
So i'm already using at my template.php this:
function carvalhar2010_preprocess_page(&$vars, $hook) {
// Render the view.
$vars['embedded_view'] = views_embed_view('works_outros', 'block_1');
//Reload the javascript into the scripts.
$vars['scripts'] = drupal_get_js();
}
and then at page.tpl:
print $embedded_view;
I'm sure the name/block of the view is OK.
So....any clue why ajax configuration isn't being added?
thanks
Comment #3
carvalhar CreditAttribution: carvalhar commentedok this solution above worked.
I had to flush theme cache...
that' ok now :)