Closed (won't fix)
Project:
Lost & found issues
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
31 Mar 2007 at 03:47 UTC
Updated:
26 May 2015 at 09:44 UTC
Jump to comment: Most recent
Comments
Comment #1
JohnG-1 commentedOK I've created a printable.css (so it won't get overwritten on upgrades) in my theme folder, and I want to call it in printable.tpl.php as the only stylesheet to be applied to printable pages.
Popular wisdom (a drupal.org search) suggests that patching this line into the tpl.php header should do the trick, but it don't be working for me:
Please can anyone see where I'm going wrong ?
Comment #2
nedjoWe could add this in the module (
drupal_add_css(drupal_get_path('module', 'printable') .'/printable.css');. Want to post your version? If we can get a generic version that generally works, I'll add it to the module. Then people can overwrite it in their own themes if they want.Comment #3
JohnG-1 commented@ nedjo
I have doubts that a generic printable.css could do a good job for all possible themes; I suspect it would always need a little bit of manual tuning. I really like the idea that to configure your printable theme you just manually edit the very simple printable.tpl.php and printable.css files to suite. It saves so much impossible UI and really is not difficult at all. The trick, therefore, is to keep these 2 'template' files as simple as possible.
A) Default printable.css & printable.tpl.php template files :
The problem with including printable.css and printable.tpl.php templates in the tarball is that they will be overwritten everytime the the module is updated - obliterating any custom tweaks ... to create custom copies would require manually editing the filename references in the module, which of course would be overwritten on module update ;)
So how about this trick ?:
1. (When the tarball extracts) add an empty subfolder: modules/printable/custom_theme. If it's empty by default, nothing in here will get overwritten on update.
2. When the module is looking for the printable.tpl.php to use, it first checks the custom_theme folder and only if printable.tpl.php doesn't exist there, it uses the /module/printable/printable.tpl.php instead.
3. Instruct the user (via comments at the top of both css and tpl.php files):
"Do not edit these templates! or your custom tweaks will be lost when this module is updated. Instead, make copies of the printable.tpl.php and printable.css files (in /modules/printable/ ) and drop them into the custom_theme folder (/modules/printable/custom_theme/). Edit them there and your world will be a better place."
B) How to reference the printable.css stylesheet from printable.tpl.php ?
There's nothing to prevent us from having all methods ready to roll in the printable.tpl.php header - just have one active by default and the other(s) commented out.
1.
(drupal_add_css(drupal_get_path('module', 'printable') .'/printable.css');AFAIK this method appends the printable.css to the list of all stylesheets. My understanding is that because printable.css is last in the list, it can override any other css command in any of the other stylesheets (from themes and other modules). But this means that printable.css commands would have to be relative to the gamut of other stylesheets; thus heavily customised according to the themes and modules used on a particular site... Tracking some background effect you don't like to it's parent (theme/module) stylesheet in order to intercept the css function in printable.css can be a bit of a nightmare :(
2.
<style type="text/css" media="print">@import "<?php print base_path() . path_to_theme() ?>/printable.css";</style>IMO the unstyled printable.tpl.php HTML output is pretty clear, and doesn't require a lot of styling. What I had in mind was a standalone printable.css which would not have to deal with css commands from other stylesheets, allowing it to be a much smaller and simpler file to keep edited up to date - mine would set a decent typeface and have more 'display: none;' commands than anything else ;). I thought this would be possible by making it the only stylesheet reference in the printable.tpl.php headers ... but according to http://drupal.org/node/102840#comment-192097 this seems to require a tweak to core : includes/theme.inc (in 4.7.x at least).
Comment #4
JohnG-1 commentedB) 3.
<style type="text/css" media="print">@import "<?php print printable_get_path() ?>/printable.css";</style>just a variation on B) to if the changes in A) were implemented : printable_get_path() = the custom function in printable.module ... if this would work ?
Comment #5
jcnventuraThis module is no longer maintained. Closing the issue.