Actions

Difference between revisions of "Customizing the print pop-up"

From Joomla! Documentation

m (Adjusted link after page move)
 
(3 intermediate revisions by 3 users not shown)
Line 4: Line 4:
  
 
At the heart of component.php is:
 
At the heart of component.php is:
 
+
<source lang="html4strict">
 
  <head>
 
  <head>
 
  <jdoc:include type="head" />
 
  <jdoc:include type="head" />
Line 18: Line 18:
 
   </body>
 
   </body>
 
  </html>
 
  </html>
 
+
</source>
Pop-up only Styles
+
==Pop-up only Styles==
  
 
To add a specific stylesheet for your print pop-up, simply change the stylesheet in the head section to one that suits your needs. I'd also recommend using the media attribute to limit this new stylesheet to print and / or screen. For example our head may now look like:
 
To add a specific stylesheet for your print pop-up, simply change the stylesheet in the head section to one that suits your needs. I'd also recommend using the media attribute to limit this new stylesheet to print and / or screen. For example our head may now look like:
 
+
<source lang="html4strict">
 
  <head>
 
  <head>
 
  <jdoc:include type="head" />
 
  <jdoc:include type="head" />
 
  <link rel="stylesheet" href="/<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/screen.css" type="text/css" media="screen print" />
 
  <link rel="stylesheet" href="/<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/screen.css" type="text/css" media="screen print" />
 
  </head>
 
  </head>
 
+
</source>
 
Depending on whether or not you have separated your stylesheets by form and function, you could even use @import to grab your typography, module overrides, browser normalization rules and other styles. In some cases you may need to add a few extra lines of CSS to our new screen.css file to override some of your other rules. For example, screen.css could look like:
 
Depending on whether or not you have separated your stylesheets by form and function, you could even use @import to grab your typography, module overrides, browser normalization rules and other styles. In some cases you may need to add a few extra lines of CSS to our new screen.css file to override some of your other rules. For example, screen.css could look like:
 
+
<source lang="css">
 
  @import url('normalization.css');
 
  @import url('normalization.css');
 
  @import url('typography.css');
 
  @import url('typography.css');
Line 38: Line 38:
 
  img{border:none}
 
  img{border:none}
 
  .componentheading {background:none;color:#000;font-weight:bold;padding-top:20px;width:100%;text-align:center}
 
  .componentheading {background:none;color:#000;font-weight:bold;padding-top:20px;width:100%;text-align:center}
 
+
</source>
Pop-up only Modules
+
==Pop-up only Modules==
 
Component.php allows for the same code to be used for creating module positions. This can be especially useful if you want a specific header image or content displayed on only certain articles when they are printed. To add a module position, use the same code that you would with index.php.
 
Component.php allows for the same code to be used for creating module positions. This can be especially useful if you want a specific header image or content displayed on only certain articles when they are printed. To add a module position, use the same code that you would with index.php.
 
+
<source lang="html4strict">
 
  <jdoc:include type="modules" name="popup" />
 
  <jdoc:include type="modules" name="popup" />
 
+
</source>
 
Since we want this to be displayed only certain print pop-ups, I use the countModules method. For example:
 
Since we want this to be displayed only certain print pop-ups, I use the countModules method. For example:
 
+
<source lang="php">
 
  <?php if ($this->countModules('popup')) : ?>
 
  <?php if ($this->countModules('popup')) : ?>
 
   <jdoc:include type="modules" name="popup" style="raw" />
 
   <jdoc:include type="modules" name="popup" style="raw" />
 
  <?php endif; ?>
 
  <?php endif; ?>
 
+
</source>
 
Now, you can create a new module to contain whatever content or images that you'd like, assign it to your newly created position ("popup" in this example) and control when it appears by use of menu assignments.
 
Now, you can create a new module to contain whatever content or images that you'd like, assign it to your newly created position ("popup" in this example) and control when it appears by use of menu assignments.
  
 
The final contents of your new component.php could look like:
 
The final contents of your new component.php could look like:
 
+
<source lang="html4strict">
 
  <head>
 
  <head>
 
  <jdoc:include type="head" />
 
  <jdoc:include type="head" />
Line 66: Line 66:
 
  </body>
 
  </body>
 
  </html>
 
  </html>
 +
</source>
 +
==References==
 +
*[http://www.theartofjoomla.com/reference/17-templates/60-the-popup-template-file.html The Art of Joomla]
 +
*[[Creating a basic Joomla! template]]
 +
*[[Counting modules in a given module position]]
  
 
+
[[Category:Template Development]]
 
+
[[Category:Templates]]
Refrences:
+
[[Category:Tutorials]]
*[http://www.theartofjoomla.com/reference/17-templates/60-the-popup-template-file.html The Art of Joomla]
+
*[[Tutorial:Creating_a_basic_Joomla!_template]]
+
*[[Counting_modules_in_a_given_module_position]]
+

Latest revision as of 08:44, 16 January 2011

As Andrew Eddie at The Art of Joomla reports, the file /templates/$template/component.php controls the print view of a given article. Component.php acts just like index.php, which controls your template layout, module positions and CSS, among other things.

Component.php can be equally customized with features like module positions and custom CSS files. This is done using the same methods as with index.php.

At the heart of component.php is:

 <head>
 <jdoc:include type="head" />
   <link rel="stylesheet" href="/<?php echo $this->baseurl ?>/templates/system/css/general.css" type="text/css" />
   <link rel="stylesheet" href="/<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/template.css" type="text/css" />
   <?php if($this->direction == 'rtl') : ?>
    <link rel="stylesheet" href="/<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template_rtl.css" type="text/css" />
  <?php endif; ?>
  </head>
  <body class="contentpane">
   <jdoc:include type="message" />
   <jdoc:include type="component" />
  </body>
 </html>

Pop-up only Styles

To add a specific stylesheet for your print pop-up, simply change the stylesheet in the head section to one that suits your needs. I'd also recommend using the media attribute to limit this new stylesheet to print and / or screen. For example our head may now look like:

 <head>
 <jdoc:include type="head" />
 <link rel="stylesheet" href="/<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/screen.css" type="text/css" media="screen print" />
 </head>

Depending on whether or not you have separated your stylesheets by form and function, you could even use @import to grab your typography, module overrides, browser normalization rules and other styles. In some cases you may need to add a few extra lines of CSS to our new screen.css file to override some of your other rules. For example, screen.css could look like:

 @import url('normalization.css');
 @import url('typography.css');
 @import url('modules.css');
 @import url('style.css');
 html, body{background: #FFF}
 input {border:1px solid #666;}
 img{border:none}
 .componentheading {background:none;color:#000;font-weight:bold;padding-top:20px;width:100%;text-align:center}

Pop-up only Modules

Component.php allows for the same code to be used for creating module positions. This can be especially useful if you want a specific header image or content displayed on only certain articles when they are printed. To add a module position, use the same code that you would with index.php.

 <jdoc:include type="modules" name="popup" />

Since we want this to be displayed only certain print pop-ups, I use the countModules method. For example:

 <?php if ($this->countModules('popup')) : ?>
  <jdoc:include type="modules" name="popup" style="raw" />
 <?php endif; ?>

Now, you can create a new module to contain whatever content or images that you'd like, assign it to your newly created position ("popup" in this example) and control when it appears by use of menu assignments.

The final contents of your new component.php could look like:

 <head>
 <jdoc:include type="head" />
 <link rel="stylesheet" href="/<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/screen.css" type="text/css" media="screen print" />
 </head>
 <body class="contentpane">
        <?php if ($this->countModules('popup')) : ?>
        <jdoc:include type="modules" name="popup" style="raw" />
      <?php endif; ?>
    <jdoc:include type="message" />
    <jdoc:include type="component" />
 </body>
 </html>

References