It is currently Sat Oct 11, 2008 6:32 pm

 

All times are UTC


Forum rules

Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Print Page / Email Page - different 'template'
PostPosted: Thu Jan 25, 2007 2:33 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Fri Dec 22, 2006 2:56 am
Posts: 65
Location: Adelaide, Australia
Is there a condition that I can include to supply different code for the 'email and 'print page' pop-up windows?

My client wanted to have his logo and address details included like a letterhead when people use the print page function. Good idea, no problem! - I cleverly included the code for that in index2.php, about line 145, also changed it to use a better stylesheet for print.

Problem is, the code that I included now also shows up in the 'email' pop-up window - they use the same bit of code.

So some kind of 'if' condition would be nice so that I prevent the branding elements that I included from showing on the email pop-up.

Here's the code that I would expect to modify from index2.php:

Code:
// start basic HTML
// this is the 'print page' html ... also the email page
if ( $no_html == 0 ) {
   $customIndex2 = 'templates/'. $mainframe->getTemplate() .'/index2.php';
   if (file_exists( $customIndex2 )) {
      require( $customIndex2 );
   } else {
      // needed to seperate the ISO number from the language file constant _ISO
      $iso = split( '=', _ISO );
      // xml prolog
      echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';
   ?>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
         <?php echo $mainframe->getHead(); ?>
// next line is modified to use a different style sheet
         <link rel="stylesheet" href="templates/<?php echo $cur_template;?>/css/print_css.css" type="text/css" />
         <meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" />
         <meta name="robots" content="noindex, nofollow" />
         <?php if ($my->id || $mainframe->get( 'joomlaJavascript' )) { ?>
         <script language="JavaScript" src="<?php echo $mosConfig_live_site;?>/includes/js/joomla.javascript.js" type="text/javascript"></script>
         <?php } ?>
      </head>
      <body class="contentpane">
// here's where I added the print logo & address details
<?php mosMainBody(); ?>
      </body>
   </html>


Interestingly, my 'contact us' page still includes the web css, but thats a minor problem that I can probably eventually solve.

Im sure its dead easy when you know how.
Thanks for reading this far.

_________________
Joomla 1.0.12  -  Community Builder 1.0.2  -  Joomla-SMF  2.0.2  -  CiviCRM 1.6.8124  -  OpenSEF 2.0.0-RC5_SP2  -  JEvents v1.4.0  -  PHP 4.4.4


Last edited by GarlicBred on Tue Jul 17, 2007 4:40 pm, edited 1 time in total.

Top
 Profile E-mail  
 
 Post subject: Re: Print Page / Email Page - different 'template'
PostPosted: Sat Jan 27, 2007 12:13 am 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Fri Dec 22, 2006 2:56 am
Posts: 65
Location: Adelaide, Australia
Any ideas?
Its just a kind of:
if (print page)  <-- this is the condition I'm having trouble with, rest is easy
write this (the print page code)
else (continue)

Gotta be real easy for an experienced joomla programmer, but would take me all day to figure the "if (print page)" bit.... Im sooo tired of spending all day on every little bit of php customisation.

And I'd say this would be extensively used, because who wouldn't want their own branding bits on their printed pages?
Otherwise I'll just remove the email link from the site & hope that pop-up code isnt used in anything else.

_________________
Joomla 1.0.12  -  Community Builder 1.0.2  -  Joomla-SMF  2.0.2  -  CiviCRM 1.6.8124  -  OpenSEF 2.0.0-RC5_SP2  -  JEvents v1.4.0  -  PHP 4.4.4


Top
 Profile E-mail  
 
 Post subject: Re: Print Page / Email Page - different 'template'
PostPosted: Sat Jan 27, 2007 2:57 am 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Fri Dec 22, 2006 2:56 am
Posts: 65
Location: Adelaide, Australia
GOT IT!!

Code:
<? if ($page=="0") { ; ?>


was what I was looking for. I figured it by comparing the URLs of the print page to the email page & a bit of guesswork.

Here's the complete code for adding your own letterhead to your print pages, without it interfering with the email page pop-up box:

In index2.php, about line 122

Code:
// start basic HTML
// this is the 'print page' html ... also the email page ... nothing has changed here until around the stylesheet area
if ( $no_html == 0 ) {
   $customIndex2 = 'templates/'. $mainframe->getTemplate() .'/index2.php';
   if (file_exists( $customIndex2 )) {
      require( $customIndex2 );
   } else {
      // needed to seperate the ISO number from the language file constant _ISO
      $iso = split( '=', _ISO );
      // xml prolog
      echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';
   ?>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
         <?php echo $mainframe->getHead(); ?>
         <meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" />
         <meta name="robots" content="noindex, nofollow" />
         <?php if ($my->id || $mainframe->get( 'joomlaJavascript' )) { ?>
         <script language="JavaScript" src="<?php echo $mosConfig_live_site;?>/includes/js/joomla.javascript.js" type="text/javascript"></script>
         <?php } ?>
         <link rel="stylesheet" href="templates/<?php echo $cur_template;?>/css/print_css.css" type="text/css" />
      </head>
      <body class="contentpane">
<? if ($page=="0") { ; ?>
<table width="100%" > ... or whatever you want your print header to be ... </table>
      <?php } mosMainBody(); ?>
      </body>
   </html>


The style sheet is still a minor problem - on some pages the web css gets inserted after the print one, thus overriding it.
It doesnt work for some pages eg com_contact, & probably loads of other situations... but its a start.

I need to identify the components that use it, find a test for it, and include it somehow as an "or" condition in my "if" statement

Hope that is useful for some people.

_________________
Joomla 1.0.12  -  Community Builder 1.0.2  -  Joomla-SMF  2.0.2  -  CiviCRM 1.6.8124  -  OpenSEF 2.0.0-RC5_SP2  -  JEvents v1.4.0  -  PHP 4.4.4


Top
 Profile E-mail  
 
 Post subject: Re: Print Page / Email Page - different 'template'
PostPosted: Sun Mar 25, 2007 4:09 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Thu Mar 22, 2007 5:04 pm
Posts: 4
Any chance you can show me what your print css is? Thanks  :)


Top
 Profile E-mail  
 
 Post subject: Re: Print Page / Email Page - different 'template'
PostPosted: Sun Mar 25, 2007 5:54 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Fri Dec 22, 2006 2:56 am
Posts: 65
Location: Adelaide, Australia
My print css is not elegant. Theres loads of unneccessary definitions, and my styles may not suit your styles. But if you want to see it its here:
http://fiscalstar.com.au/templates/fiscal/css/print_css.css
One good point is that it uses relative sized fonts.

Also, for sake of updating this thread, my previous code didnt work so well.
this works better in index2.php about line 150:

Code:
<?
if ($task=="view") { ; ?>
<table width="100%" ><tr ...etc



so thats instead of the
Code:
<? if ($page=="0") { ; ?>

as previously posted.

Hope that helps.

_________________
Joomla 1.0.12  -  Community Builder 1.0.2  -  Joomla-SMF  2.0.2  -  CiviCRM 1.6.8124  -  OpenSEF 2.0.0-RC5_SP2  -  JEvents v1.4.0  -  PHP 4.4.4


Top
 Profile E-mail  
 
 Post subject: Re: Print Page / Email Page - different 'template'
PostPosted: Sun Mar 25, 2007 5:58 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Thu Mar 22, 2007 5:04 pm
Posts: 4
Ah thanks! That little edit works like a charm. Great job.  :)


Top
 Profile E-mail  
 
 Post subject: Re: Print Page / Email Page - different 'template'
PostPosted: Wed Aug 22, 2007 9:53 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Thu Aug 18, 2005 8:20 am
Posts: 80
Location: Paris
Just want to say thanks if you are still out there on the forum!  :D 

I expected a print css  option by default as it is a pretty basic function to have a print style sheet but couldn't find anything until this very  useful post.  I am not using the email so the original code worked like a charm. But if the email icon is showing, it is great to know how to separate them.

yay!

Julie

_________________
http://julievetter.com


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group