0

I'm writing a module for Drupal 7 that gives every user with the right permissions a new page in his profile. I want this page to only display the Drupal header and a div with a specific ID, for a JS web app to attach itself to. AFAIK, the easiest way to do this would be by using a template file that only prints those two things.

From what I read in Create a template for a custom page in Drupal 7?, I just need to create a page--user--%--POD.tpl.php file, which I have (the new page resides at the path user/%/POD). I have als added this file to my .info file.

name = Module with some template problems

...

files[] = page--user--7--POD.tpl.php

As a way of minimizing factors, I've started by creating a page for user 7 only, but this will have to work for any user eventually. I have uninstalled the module, cleared all caches and reinstalled it again, but it still doesn't get used when I browse to user/7/POD.

Any help would be greatly appreciated.

According to https://drupal.org/node/1089656, the correct hook suggestion that I need to implement would be page--user--POD.tpl.php. I've renamed my template file accordingly. No success yet.

5
  • @kiamlaluno if you delete the solution I found, could you at least let me know why, so I can stick to the protocol next time? I can't seem to figure out how holding back possible answers is going to help anyone.
    – Simon
    Mar 19 '14 at 0:06
  • I forgot to comment on that; I apologize. Questions are for asking a question; if you have found the solution to your problem, wait you are allowed to write an answer, and answer your own question. This is a Q&A site, not a forum; answers are required to be separated from the question. See the revisions list, if you forgot what you wrote.
    – apaderno
    Mar 19 '14 at 13:24
  • The reason I posted it in an edit is because I couldn't figure out the logic behind the minimum waiting time before one is allowed to answer his own questions. It doesn't seem logical to hide answers if I found one, that would just waste others' time, would it not? Anyways, I'll stick to the protocol, just would be nice to see the reasoning behind it ;)
    – Simon
    Mar 22 '14 at 0:22
  • Users who have few experience with Stack Exchange sites (i.e. low reputation) tend to write as answer something that would be an edit for the question; that is one of the reasons why those users are required to wait X hours before writing an answer. The other reason is avoiding they write their own answer before other users had the chance to answer the question.
    – apaderno
    Mar 22 '14 at 3:49
  • Cool, thanks. Will stick to the protocol next time. Sorry for the inconvenience ;)
    – Simon
    Mar 23 '14 at 11:36
0

I found a solution at https://drupal.org/node/715160 .

Apparently, in order to do this, you need to alter the theme registry in order to let Drupal know that there are templates to be found in your module's directory. You can specify which hooks it can find modules for and what path(s) it needs to search.

0

I believe the original template name you had with the percent symbol was correct. The problem is you are doing it in a module, not in a theme.

By default, you have to put the template in your theme for it to be picked up automatically.

Also, in module info files, the use of files[] = something.ext is only for files that contain classes, so Drupal can autoload them. Files like template files, module files, installation files, etc. don't go in there.

3
  • Thanks for your answer. So, there is no way for me to override the default page template on my newly created page from within the module? Surely, there must exist something I can use to get rid of everything except the header?
    – Simon
    Mar 17 '14 at 11:58
  • Yeah there is a way. I will update my answer with it in a little while if no one else beats me to it.
    – rooby
    Mar 17 '14 at 23:45
  • I already found an answer. Apparantly, kiamlaluno didn't really like me posting that. I have no idea why. Feel free to check the revisions to see what I found and add a better answer if you have one :) Thanks!
    – Simon
    Mar 19 '14 at 0:04

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.