I created a long order form for a website that launched in December. This duplicated a function from the pre-Drupal site and it basically just emails the form to the site owner, it is not an e-commerce function. There are a lot of items on the form and now they are complaining that the form prints out as 3 pages even if the person orders only one item.
Is there a way to make the form print only the fields that have a user response and not the empty fields?
You can see the form here: http://www.urbanorganic.com/node/47
Thanks,
On Tue, 29 Jan 2008 13:40:39 -0500 "Jean Gazis" jgazis@gmail.com wrote:
I created a long order form for a website that launched in December. This duplicated a function from the pre-Drupal site and it basically just emails the form to the site owner, it is not an e-commerce function. There are a lot of items on the form and now they are complaining that the form prints out as 3 pages even if the person orders only one item.
I think it depends on how you're sending the stuff they have to print... one way would be to have a custom theme_ function for the form that just unset the form items that are empty and then just call
$output .= drupal_render($form);
The form is submitted as email. Where would the theme function be? In the main site theme or in a separate place? (I'm not a programmer so I will need this in baby steps, I'm afraid. I can cut and paste snippets, etc. )
Thanks for your quick response!
jean
On Jan 29, 2008 1:53 PM, Ivan Sergio Borgonovo mail@webthatworks.it wrote:
On Tue, 29 Jan 2008 13:40:39 -0500 "Jean Gazis" jgazis@gmail.com wrote:
I created a long order form for a website that launched in December. This duplicated a function from the pre-Drupal site and it basically just emails the form to the site owner, it is not an e-commerce function. There are a lot of items on the form and now they are complaining that the form prints out as 3 pages even if the person orders only one item.
I think it depends on how you're sending the stuff they have to print... one way would be to have a custom theme_ function for the form that just unset the form items that are empty and then just call
$output .= drupal_render($form);
-- Ivan Sergio Borgonovo http://www.webthatworks.it
-- [ Drupal support list | http://lists.drupal.org/ ]
That's quite simple actually and has nothing to do with drupal. Create a print css file and include that. set display:none on any element you don't need and do any other tweaks you need to get it looking right. Use the media attribute: <style type="text/css" media="Print"></style> OR <link rel="Stylesheet" href="print.css" media="Print" />
You can set it as the main css file while you're working on it so that you don't waste tons of paper seeing how it looks, then switch it ot the print one when it's right.
Whenever anyone clicks print it will use that css instead. I include it on almost all of my sites.
.s
Jean Gazis wrote:
I created a long order form for a website that launched in December. This duplicated a function from the pre-Drupal site and it basically just emails the form to the site owner, it is not an e-commerce function. There are a lot of items on the form and now they are complaining that the form prints out as 3 pages even if the person orders only one item.
Is there a way to make the form print only the fields that have a user response and not the empty fields?
You can see the form here: http://www.urbanorganic.com/node/47
Thanks,
-- Jean Gazis www.jeangazis.com http://www.jeangazis.com www.boxofrain.us http://www.boxofrain.us
"Believe those who are seeking the truth; doubt those who find it." - André Gide
Will the print css output to the email? The form submission is emailed to someone and then they print it.
On Jan 29, 2008 2:43 PM, sander-martijn lists@severeddreams.com wrote:
That's quite simple actually and has nothing to do with drupal. Create a print css file and include that. set display:none on any element you don't need and do any other tweaks you need to get it looking right. Use the media attribute:
<style type="text/css" media="Print"></style>
OR
<link rel="Stylesheet" href="print.css" media="Print" />
You can set it as the main css file while you're working on it so that you don't waste tons of paper seeing how it looks, then switch it ot the print one when it's right.
Whenever anyone clicks print it will use that css instead. I include it on almost all of my sites.
.s
Jean Gazis wrote:
I created a long order form for a website that launched in December. This duplicated a function from the pre-Drupal site and it basically just emails the form to the site owner, it is not an e-commerce function. There are a lot of items on the form and now they are complaining that the form prints out as 3 pages even if the person orders only one item.
Is there a way to make the form print only the fields that have a user response and not the empty fields?
You can see the form here: http://www.urbanorganic.com/node/47
Thanks,
-- Jean Gazis www.jeangazis.com http://www.jeangazis.com www.boxofrain.us http://www.boxofrain.us
"Believe those who are seeking the truth; doubt those who find it." - André Gide
-- [ Drupal support list | http://lists.drupal.org/ ]
Oh I don't know. If the email is an html email then there's no reason why it wouldn't you just have to make sure that the print css is in the email. If it's a plain text email then thare won't be any effect. Sorry, I missed the emailing part.
Jean Gazis wrote:
Will the print css output to the email? The form submission is emailed to someone and then they print it.
On Jan 29, 2008 2:43 PM, sander-martijn <lists@severeddreams.com mailto:lists@severeddreams.com> wrote:
That's quite simple actually and has nothing to do with drupal. Create a print css file and include that. set display:none on any element you don't need and do any other tweaks you need to get it looking right. Use the media attribute: <style type="text/css" media="Print"></style> OR <link rel="Stylesheet" href="print.css" media="Print" /> You can set it as the main css file while you're working on it so that you don't waste tons of paper seeing how it looks, then switch it ot the print one when it's right. Whenever anyone clicks print it will use that css instead. I include it on almost all of my sites. .s Jean Gazis wrote: > I created a long order form for a website that launched in December. > This duplicated a function from the pre-Drupal site and it basically > just emails the form to the site owner, it is not an e-commerce > function. There are a lot of items on the form and now they are > complaining that the form prints out as 3 pages even if the person > orders only one item. > > Is there a way to make the form print only the fields that have a user > response and not the empty fields? > > You can see the form here: http://www.urbanorganic.com/node/47 > > Thanks, > > -- > Jean Gazis > www.jeangazis.com <http://www.jeangazis.com> <http://www.jeangazis.com> > www.boxofrain.us <http://www.boxofrain.us> <http://www.boxofrain.us> > > "Believe those who are seeking the truth; doubt those who find it." - > André Gide > -- [ Drupal support list | http://lists.drupal.org/ ]-- Jean Gazis www.jeangazis.com http://www.jeangazis.com www.boxofrain.us http://www.boxofrain.us
"Believe those who are seeking the truth; doubt those who find it." - André Gide
On Tue, 29 Jan 2008 14:43:37 -0500 sander-martijn lists@severeddreams.com wrote:
That's quite simple actually and has nothing to do with drupal. Create a print css file and include that. set display:none on any element you don't need and do any other tweaks you need to get it
It won't work. At least it won't be enough and since this stuff is going to get through an email client I would prefer to avoid relying on css, not because you can't send them by email... but because you can't be that sure they will render as you expect.
He has to hide fields conditionally... so he has to apply the css conditionally and I think the best place should be the theme hook.
I'm guessing Jean has something like:
$output.=drupal_get_form('hisform'); some_mail_function($To,$From,$output);
I'm also guessing that the content of the form is saved somewhere (DB) so that the content of the form can be reloaded.
function hisform() { $result=db_query('....'); $row=db_fetch_object($result);
$form['field']=Array( '#type'=>'textfield', '#default_value'=>$row->somecolumn, ); ...
}
Unfortunately my first guess was wrong since the theme function doesn't know about the values in the form.
So hiding fields have to be done in the form function along the line:
$output.=drupal_get_form('hisform','hide'); some_mail_function($To,$From,$output);
function hisform($type) { $result=db_query('....'); $row=db_fetch_object($result);
$form['field']=Array( '#type'=>'textfield', '#default_value'=>$row->somecolumn, );
/* if you use select, checkboxes etc, this part will be more complicated */ foreach($form as $key => $value) { if(is_null($form[$key]['#default_value] && $type='hide' ) { $form[$key]['#attributes']=Array('class'=>'ImHidden'); //or //unset($form[$key]); } } }
sort of
But some more hints from Jean would help.