5

I read several answers about "Is it better to develop your own theme from scratch or extend a existing one?".

Here is my situation: I just got an existing project and I have to debug it and evolve it. I'm in the audit phase and I was wondering if, in a theme developed from scratch, you forgot to provide the code for render some elements, are they going to stay hidden?

The specific case in this project is the absence of drupal status messages. They never appear. I guess there are plenty of them that are generated by the core, like when you fail at login or something. But they just don't happen.

It is very problematic and I want to fix that.

Is that because developers forgot to render them manually somewhere?

Thanks in advance

3 Answers 3

6

if, in a theme developed from scratch, you forgot to provide the code for render some elements, are they going to stay hidden?

Yes, of course - if you develop a theme and override core templates, anything that's left out will remain left out. There's no magic in Drupal, it's just PHP at the end of the day. Think of it from the other side of the equation - if you were building a theme from scratch, and Drupal kept injecting markup into your templates without your say-so, wouldn't that be a crazy state of affairs?

Is that because developers forgot to render them manually somewhere?

That's impossible to say from here. Could be that, could be some rogue CSS hiding them, could be a theme override of status messages nulling the output, and a bunch of others besides. The only way to know is to have a look and see what's there.

If the theme follows any sort of convention at all you should be able to look for a variable called $messages for the status messages. Usually it's located in page.tpl.php.

What you're essentially asking is akin to "I've built a car from scratch, if I leave out the brakes with someone else put them in for me?". The answer is "Only if someone intervenes manually; the assembly line won't do it automatically".

1
  • 2
    Alright. You just confirmed my thoughts. But because I'm still a junior, you know, I prefer to be sure ;-) There is indeed no trace of any rendering of messages in their templates, and no barbarian CSS to hide something. The only thing I'm sure: they built the theme from scratch. Now I can affirm that they didn't provide a status messages redering. Thanks a lot.
    – Djouuuuh
    Commented Oct 24, 2014 at 9:40
1

I really like starting from scratch, but mainly after I got a good base theme going.

My approach is to use a few template files from modules/system/ specifically html.tpl.php and page.tpl.php that way you have a good overview of available variables.

In your case I'd have a look at the Drupal API docs for page.tpl.php and that way anything that isn't being rendered you can render. (It's unlikely that anything is actually missing just un-rendered.)

1

From my experience, developping you own theme from scratch for specific needs (those can't be meet by more general theme) is a good mid-long term solution. But that require some past experience in theming.

For your absence of drupal status message, you can just download some skeleton theme (basic, bootstrap, etc) and have a look how they handle drupal status message. Maybe they just didn't print the output, have you check in the tpl files ?

For example in basic theme, in page.tpl, you have :

      <?php print $messages; ?>
      <?php print render($page['help']); ?>
1
  • Yes I checked all the templates and I didn't find any messages anywhere. I guess the guys just forgot it :) Thanks anyway
    – Djouuuuh
    Commented Oct 25, 2014 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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