Hallo,
I need to theme the "my-domain.com/comment/reply/$node->nid" page.
With the devel modul I can see the theme_hook_suggestions:
- page__comment
- page__comment__reply
- page__comment__reply__%
- page__comment__reply__27
Well here is my problem:
I have a "page--blog.tpl.php" a "page--book.tpl.php" and a "page--forum.tpl.php". All of them have a different theme or rather css layout.
On every page my users can post comments.
If my users preview their comments they always see the "page--comment--reply.tpl.php".
How can I make the comment preview like that:
If a user post a comment to a blog post, the preview page is the "page--comment--reply--blog.tpl.php".
If a user post a comment to a book post, the preview page is the "page--comment--reply--book.tpl.php".
If a user post a comment to a forum post, the preview page is the "page--comment--reply--forum.tpl.php".
You can see my problem in the attachment too.
Comment | File | Size | Author |
---|---|---|---|
forum-theme-.jpg | 26.73 KB | falloutboy | |
blog-theme-.jpg | 24.92 KB | falloutboy |
Comments
Comment #2
Konstantin Boyandin CreditAttribution: Konstantin Boyandin commentedDefinitely, something should be done about comment/reply
Apart from possibility to assign per-node type template for comment/reply, a special type of aliases is suggested to add. So that the actual page address looked like
nodetypename/comment/reply/nid
i.e.
blog/comment/reply/12345
Comment #3
heretic381 CreditAttribution: heretic381 commentedAny news for this issue?
A major fix is needed here, as comment reply page breaks the page per content-type custom templates.
Comment #4
NaheemSays CreditAttribution: NaheemSays commentedYou can add further theme suggestions as needed:
https://drupal.org/node/1142800#comment-4433994
Comment #5
heretic381 CreditAttribution: heretic381 commentedHi,
I don't really see what are trying to point out here.
I know how to make a template per content type and I'm already using them.
The problem is that whatever template we are using, the comment-reply page is not related to it. If someone posts a comment on certain type of node, he's going to click on create new comment, or reply link and the page he's going to be redirected to is using page.tpl.php (or at best page--comment--reply.tpl.php) and that is not always what we want. We need a different template for comment reply page per content type.
Thanks.
Comment #6
NaheemSays CreditAttribution: NaheemSays commentedSomething like this in your theme template .php
Comment #7
heretic381 CreditAttribution: heretic381 commentedThanks for the idea. But, I'm not skilled enough in php and drupal API to figure out how to make this work.
"//figure out how to load node. comment id is $args[2]."
Comment #8
NaheemSays CreditAttribution: NaheemSays commentedoops $args[2] was the nid.
The full function you need is:
Comment #9
heretic381 CreditAttribution: heretic381 commentedWhen changed "page--comment--reply--$node->type" to 'page__comment__reply__'.$node->type'
it worked.
Thanks.
Comment #10
NaheemSays CreditAttribution: NaheemSays commentedComment #11
ShaneOnABike CreditAttribution: ShaneOnABike commentedI *hate* to re-open this but actually I realized an issue here with comments.
On a regular page the comments section calls the hook comments_wrapper and also the appropriate template. For some bizarre reason there isn't an equivalent hook nor template file for comments replies :(
Thoughts? I think the title is still fairly relevant actually.
Comment #12
Pasqualleif you want a different comment.tpl.php template per node type
https://api.drupal.org/api/drupal/7/search/preprocess_comment
If you need something else, please explain your issue a bit more.
Comment #13
bdanin CreditAttribution: bdanin commentedSo when you add this to your template.php file:
You can then copy your page.tpl.php into page--comment--reply.tpl.php (don't forget to clear caches!), to theme all comment-reply page templates, or you can also add page--comment--reply--CONTENTTYPE.tpl.php for specific content-type pages.
This seems like it fits well within the standard "Drupal way" of theming for reply-pages.