0

This question here at DA has a popular suggestion to check page.tpl.php to see if it says print $messages;. I verified this and this is the case.

I cleared caches many times, btw after which there actually is a drupal message saying the caches are cleared.

I made sure the dpm(), dsm() or drupal_set_message() functions are nicely outside any conditional statement or php logic whatsoever. I also put all these functions on different places in the tpl file. Still no result.

The same theme also has another tpl file that I used before and had some commented dpm(); functions that I uncommented but these didn't work anymore either.

Devel module is enabled and I am logged in as admin the whole time.

  • I think what you are experiencing is a timing issue for no better explanation. If you look in includes/bootstrap.inc you will see that all the various message functions populate or look at a session variable with or for the contents of the message. These are then plucked via process_page() in includes/theme.inc which populates the $messages variable. So, if you are calling these functions INSIDE the page template, this variable has already been set, so these new messages are either lost or should/will eventually appear when a subsequent page is loaded... – Jimajamma May 29 '14 at 15:29
  • @Jimajamma is what you are suggesting still that the cause of my problem has much if not everything to do with the fact that I am trying to use, dpm();, dsm();, and even drupal_set_message(); from a tpl file? I mean, for all anyone should care for in this purpose, my end goal could be that I just want to output a hardcoded string with drupal_set_message();. If you catch my drift. – Immers May 29 '14 at 16:18
  • without seeing what exactly you are doing in your template, that's most probably correct. but since, once again, Drupal puts all of the output of these in $messages before the template it processed, using them inside the template will either, once again, not work, or will be delayed until a subsequent page load. So, if within a template, you want to have further messages displayed, you could add in logic that appends information to the $messages variable and then they would show up when it is printed, or you could do any other php coding, eg a direct print of a message yourself, etc. – Jimajamma May 30 '14 at 12:34
  • Possible duplicate of dpm() does not display any results on screen – leymannx Nov 8 '18 at 23:23
  • It's left unclear in your question if you also went through all other answers in the mentioned question, so I'm marking yours as possible duplicate. – leymannx Nov 8 '18 at 23:25
1

You have access to the entire Drupal bootstrap within template files. Template files are loading at the very end of a page request post bootstrap. If dpm() or dpr() is not working it is most likely because you are viewing the site as an anonymous user. The devel module by default does not allow access to it's functionality for anonymous users. Try logging in as admin and you should see the output of your devel module function calls.

As an F.Y.I. template files are not the typical place for a dpm() as you either need to know the variable you are after or put a get_defined_vars() calls inside it which can be quite heavy depending on where you are in stack. It is more common to use dpm()'s in template hooks such as:

Then you can see all the variables that are available to your template files.

  • I should have mentioned I was logged in as admin the whole time(I do now). That said, It shouldn't matter if templates are not a typical place for dpm(); functions. It's besides the point. The problem is I can't even use drupal_set_message();. What I want to output in these functions is besides the point too. – Immers May 29 '14 at 13:15
  • If that is the case I would suggest checking your Drupal log. There is an off chance errors are being thrown but they are not being displayed because drupal_set_message() is not working. – Jepedo May 29 '14 at 13:27
  • Thanks to your comment I noticed that even my database logging module was disabled. Enabled it off course. Also error logging was also set to 'none', which could have been a good candidate for a solution. So I also set this to 'display all'. Still though, no drupal_set_message(); results after setting both of these things straight. At the same time, if you take into consideration that the message 'Every cache cleared' actually does get output every time I clear the caches, the idea that something is holding back the messaging alltogether becomes less interesting don't you think? – Immers May 29 '14 at 14:07
0

Not a fix for your issue but a work around could be to use Devel Debug Log instead. You can use ddl($var) and will save to a log in which you can see the output on the log page. Much better than trying to spit out dpm messages in $messages variable.

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.