I have a views block that shows nodes in some conditions. The views has pager and normally it works but if I use Global: PHP field the pager doesn't work and it only show the first page.

The Global: PHP field is as below:

  • Value Code: emtpy
  • Output Code:


<?php if ($row->type == 'book') { ?>
        <i class="fa fa-book fa-lg fa-fw"></i>
<?php }
elseif ($row->type == 'article') {
        <i class="fa fa-file-text-o fa-lg fa-fw"></i>
<?php }
elseif ($row->type == 'thesis') {
        <i class="fa fa-graduation-cap fa-lg fa-fw"></i>
<?php } ?>


I'm listing the nodes in this views block. There are 3 different content types and what I want to do with this PHP field is to print an icon according to content type. The code checks the content type with if ($row->type == ...).

(End of update.)

The PHP field works correctly and gives what I want but I wonder if I do something wrong in the PHP structure.

Do you have any idea what can cause this problem?

  • 3
    hello and welcome. Please remember that bug reports are not allowed here. I'm afraid your question looks like one now. Of this is a problem with your code in that field, phrase state it more clearly.
    – Mołot
    Dec 11 '14 at 22:28
  • @Mołot hello and thanks. I think it's not a bug report; the PHP code I used maybe caused the problem. I'm editing the question and adding details.
    – herci
    Dec 11 '14 at 23:08
  • 1
    The real issue for this is here drupal.org/node/2123315
    – rooby
    Dec 12 '14 at 4:13
  • @rooby, thanks and sorry for the late replay. Yes, as you said it seems a 'bug' and there are some solutions. And also, did you remove your answer?
    – herci
    Dec 15 '14 at 19:35
  • 1
    Yep I deleted my answer because I realized it contained misinformation. The code in your question should work.
    – rooby
    Dec 15 '14 at 21:22

There is a patch for that: Pager disappears when Global: PHP used in Views 3.8

After upgrading from Views version 7.x-3.7 to 7.x-3.8, the pager was missing from all views that used Global: PHP fields.

If patch#6 does not work for you, just follow the links in comment#27

  • 1
    That issue has been marked a duplicate of drupal.org/node/2123315 which apparently has a proper fix.
    – rooby
    Dec 12 '14 at 4:13
  • 1
    Thanks, patch#6 worked correctly and solved the problem.
    – herci
    Dec 17 '14 at 17:28

For one thing I know Drupal does not like ending php tags '?>' at the end of pages and no start or ending tags in most PHP fields I have seen. If that is not the issue can you put up an image of the field from the edit screen it might help to better understand what you mean?

  • In the output code description, it says that: Code to construct the output of this field. Use <?php ?> delimiters to enclose PHP code.
    – herci
    Dec 11 '14 at 23:11
  • It does indeed say that. The other PHP code I have entered into views has told me the opposite. I will take a deeper look.
    – sareed
    Dec 11 '14 at 23:18
  • It varies depending on the developer who created the module's preference.
    – rooby
    Dec 12 '14 at 4:14

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.