Adding graphic header to the contact form

Events happening in the community are now at Drupal community events on www.drupal.org.
dhabersaat's picture

So I used cck to add an imagefield to all of my "pages" on website - so each page now as a graphic header before the content. Perfect. Except the contact form. I thought I might be able to do something similar with CCK and Views? First question I guess, is what type of node is the contact form? I was thinking I would need to create a contact_form_node.tpl.php file. I never created any type of node.tpl.php file, so I'm not sure if I'm headed down the right path here. Suggestion would be appreciated.
Thanks
Donna

Comments

Theme Developer module

Its good

Mandakini_Kumari's picture

Its very good tutorial

Mandakini Kumari

Webform

dhabersaat's picture

Thanks Matt, I tried that tutorial for a few days, but under the zen sub-theme and never got it to work. Even at the fist step, where we are testing that it is using my template.php file for it part. I ended up just using webform. That was pretty easy, I was able to add a CCK field to it like the page node. But I would prefer to use core modules instead of contributed modules - anyone want to voice their opinion here. They do say that a new version will be available for 7 the day 7 is released - that's nice. But it seems best to use core firs.?

Anyway, getting ready to deploy my first site - nervous. Trying to find good instructions so I don't forget anything - put everything is the correct spot - and make it as secure as possible. Any suggestions will be welcomed.

Core vs. contrib

todd nienkerk's picture

Can you explain what you mean by "core" here? The modules you've mentioned -- Webform and CCK -- are not core. Only stuff that comes with a standard Drupal install is considered "core," and anything download from Drupal.org is "contributed."

I wouldn't worry about using contributed modules. You won't get very far at all if you completely shun them. Virtually every Drupal site uses contributed modules and themes -- lots of them.

I also wouldn't worry about the Druapl 7.x upgrade. It's unlikely you'll actually be able to upgrade your site before contributed modules catch up. You'll probably be far too busy running and improving it over the next several months to find the time to upgrade.

Todd Ross Nienkerk
Co-founder, Four Kitchens | IRC: toddross

Todd Ross Nienkerk
Digital Strategist and Partner
Four Kitchens: Big ideas for the web
IRC: toddross

Blocks?

rho_'s picture

You might consider using a block, and defining a new region. Seems to be a bit of an overkill, but the solution would work.

So you define a new region in your theme's .info file. Now you can make that region available in in either your page.tpl.php file (if you wanted it available to every page of your site) or create a page-contact.tpl.php file (to only add to the contact page), that essentially would be a duplicate of your page.tpl.php . To add the region simply <?php print $my_region_name; ?> just before the <?php print $content; ?> call. You will likely need to clear the cache before the region appears in the admin/build/blocks form. Now you can go in the admin and place the image in a new block and assign it to that region.

It wouldn't be all that bad to just assign the region in the page.tpl.php file, and then set the "display only on the listed pages" option on the block, vs. creating a whole new tpl.php file just to limit the region.

Again, maybe overkill for what you are doing, or perhaps may not fit your requirement at all, but just throwing out another approach.

-Ryan Oles

If it were me, I'd probably

hollybeary's picture

If it were me, I'd probably just use a webform rather than the default contact form. Gives you waaaay more options and flexibility, you might not even have to create a separate page template, depending on how your header image needs to look and how good you are with css.

two shortcut method

Mandakini_Kumari's picture

I found two shortcut method

1)So I copy page.tpl.php to page-contact.tpl.php and did changes

2)A different method would be to theme the contact form not the whole page.

<?php
function YOURTHEMENAME_theme() {
  return array(
   
'contact_mail_page' => array(
     
'arguments' => array('form' => $form),
    ),          
  );
}

function
YOURTHEMENAME_contact_mail_page($form) {
 
$output = drupal_render($form);
 
$output .= '<div class="additional-text">'. t('Text to add to bottom of form') .'</div>';
  return
$output;
}
?>

Mandakini Kumari

same problem but not sure about the solution...

vpazos's picture

Hello all,

I am new in Drupal, I'm using it just for a week, version 7. I have the same problem you are talking about in this thread. I need to put information like phone, address and other things in the contact node. I was looking for several solutions with no success, and now I'm trying to add a contact.tpl.php.

Due to in the comments module, the template's name is comments.tpl.php, I copy the file page.tpl.php (of seven theme, it is in "themes\templates\seven" as contact.tpl.php file in the contact module folder ("modules\contact\"). I did some changes, clear the cache and try it with no success either.

After this, I have test for the solution you explain here, but nothing happens, the content of contact.tpl.php file is:

<?php
function seven_theme() {
  return array(
   
'contact_mail_page' => array(
     
'arguments' => array('form' => $form),
    ),
  );
}

function
seven_contact_mail_page($form) {
 
$output = drupal_render($form);
 
$output .= '<div class="additional-text">'. t('Text to add to bottom of form') .'</div>';
  return
$output;
}
?>

I have some questions:
1) the contact.tpl.php is the template which is load when contact form is executed? if not, which template file is load?
2) where I have to save this file? in module\contact\ folder?
3) Do I need to do other changes??

Thank you very muy in advance