Currently I am in a .tpl.php file, and have the following piece of code:

  <?php if ($rows): ?>
  <div class="view-content">
    <?php print $rows; ?>
  <?php elseif ($empty): ?>
  <div class="view-empty">
    <?php print $empty; ?>
  <?php endif; ?>

It seems extremely difficult to figure where the $rows variable comes from. Any good idea?


You can do it using devel module and ddebug_backtrace() api function exposed by devel..

Below is the function call stack for page.tpl.php executed using below command..

<?php dpm(ddebug_backtrace());?>

enter image description here

I believe above tpl is related to views module... $rows are generated dynamically by views module based on your views settings...

  • So I install and enable devel, then I add <?php dpm(ddebug_backtrace());?> to the code I mentioned above, and refresh the page. But nothing shows up. Am I using it in a wrong way?
    – jack2684
    Apr 22 '14 at 2:25
  • Oops, never mind, I forget to login as admin, thanks!
    – jack2684
    Apr 22 '14 at 2:27
  • Are you accessing page as admin ?
    – Anil Sagar
    Apr 22 '14 at 2:27
  • Actually it is not completely done. I did the similar thing in xdebug. The problem is I don't know where the '$rows' variable being created. I try to search keyword 'rows' in every files of the backtrace but still no clue.
    – jack2684
    Apr 22 '14 at 2:44

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.