0

I'm trying to theme a view page on Drupal 7, I used views-view--name-of-page.tpl.php

So now it's blank right? I invoked some blocks on the view page and added some divs to style but I can't seem to show the contents of the view page.

I have tried

print render ($content);   
print $content; 
print $page;

etc.

Like what we do for node. but it's not working on views template.

Can anyone suggest me?

  • I suggest to compare it to the regular page.tpl.php file and see what are you missing. – Aram Boyajyan Oct 14 '14 at 10:03
0

In this type of template file you can not use
print render ($content);
print $content;
print $page;

Instead of you can use In page template file you can only use $rows variable for display output. print $rows; for display result.

0

In view Advanced Section Theming information click Rescan template Files for your theme.

0

In the Views-> Advanced -> Other -> Theme: Information -> You need to rescan template files.

Then in your tpl

foreach ($view->style_plugin->rendered_fields as $key => $value) {

print_r($value);

}

$value will render the required values.

Hope this helps.

0

Neither $content nor $page won't work for Views templates, these variables initialized by other theme system functions (for ex. template_preprocess_page); Views provides own (different) variables, you can find them here. If you want to see what variables are available for you to use, you can open Advanced - Theme:Information - Display output and look at its comments..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.