By elvis2 on
Hi folks,
I wanted to theme the comment form and the comments for this current project. I need to call the comment form and comments into a seperate node i made. I was hoping i could get the format of
<?=comment_theme($nid)?>
to at least call the theming files for the form and actually comments. the comment form theme file can be seperate if needed.
any clues to if drupal can do this?
thanks in advance
Comments
just noticed my last post
just noticed my last post didn't include the php so here is the form i was looking for:
Theme comments
To theme the comment output you use comment.tpl.php.
Input forms do not need to use a theme (the parts are themed, but the whole form is not always run though a theme function). Depending on how you want it different you can use css to change the look or for "bigger" changes you can write a function the implements the form_alter hook and plays with the form that way.
While there is not always a theme function, the form API will call one if present. If the form is named ABC it will call theme('ABC', ...) and by default this will call theme_ABC(...). With phptemplate ou can add code to handle this as phptemplate_ABC(...) and then provide an ABC.tpl.php file to do the theming. In the case of comments are think the form name you want is 'comment_form'. Look here and search for theme_test_page() for a example of theming the form and here for how to override other theme functions.
hi nevets, thanks for the
hi nevets,
thanks for the info. my theme does not have a comment.tpl.php file. the theme was designed recently and the themer didn't add that. i do have samples but, if i add the file i do need to add something to the template.php file? so the theme files know that the output for comments has it's own theming file?
the form needs to have a theme as well due to the site structure. i am using a tabber script which needs certain elements wrapped around the form itself. see what i mean here:
http://www.camera-prices.com/drupal/sony-cyber-shot-dsc-t9
everything in those tabs are actually on a single page and are enclosed in a
any more ideas on how to do this?
thanks
You can just place a copy of comment.tpl.php in you theme dir
You can just place a copy of comment.tpl.php in you theme directory (and should not need to modify template.php) and it should be used.
As for the other part I think that should be relatively straight forward using the form_alter hook (you will need a module for this).
I am thinking something like this would work.
The idea being you define any html part that needs to go at the start of the form in $before and any trailing html in $after.
And it almost works except it does not wrap the button for whatever reason and I do not know the form API well enough to guess why.
thanks nevets - will let you
thanks nevets - will let you know if that works.
Theming forms
I guess you are looking for #prefix and #suffix. However, I'd prefer to theme forms using theme functions.
To wrap the comment form, add the following code to template.php (create template.php if necessary):
Or if you want to do it with a .tpl.php file:
In template.php
In comment-form.tpl.php:
--
The Manual | Troubleshooting FAQ | Tips for posting | Make Backups! | Consider creating a Test site.
Hello Heine, thanks for the
Hello Heine,
thanks for the tips on the form portion. How about the actual comments? I would like to have control over them as well. I tried to use the comment.tpl.php file but I actually need to use theme functions I think to do what I need to do. I tried looking for a snippet for this but nothing worked, any suggestions for this?
Thanks again
Hello Heine, what you
Hello Heine,
what you provided helped for the most part. The final touch though has required me to modify the comments.module file. You can see a semi final finish at:
http://www.camera-prices.com/drupal/sony-cyber-shot-dsc-t9
scroll down to the bottom for comments section.
but, if you go to a node that has no comments then my theming still shows up:
http://www.camera-prices.com/drupal/canon-powershot-sd550-ixus-750
with no comments but a backgroud. to rid this i need to take advantage of the comment count that is done in a query within comments.module file. but, i am not sure what object / variable name it has. for example, i could simply do an if statement, if comment count is greater than 0 then show extra
$output .= "<h2> more theming here for comments</h2>";any clue to the name of the comment count object / variable?
thanks in advance
Comment Count
This is a bit late, and it looks from your site that you've already solved the problem, but I'll add this info in case it might help other readers.
You can use the nid (Node ID) value in the comment object to get the parent node as an object. The node object has a comment_count value. Here is the code you might use:
Very useful in a lot of situations.
Thanks for sharing that... I
Thanks for sharing that... I will remember this thread in the future.
Drupal 5 uses drupal_render instead of form_render
Just thought I should update this since it caused me problems.
Don't use form_render in Drupal 5.x. Use drupal_render instead.
show only the EMAIL ADRESS line on the comment form
Hi,
Can you tell me how to do to show only the EMAIL ADRESS line on the comment form so that people can receive an email notification when they publish an email and need a reply ?
(the complete core form with name and website is useless and gives the feeling that too many info are needed)
Thanks for help.