By eliza411 on
I have spent a long time theming a complex cck content type, and I would love to have a printer-friendly view that just removed all the navigational elements, much like the printer-friendly module does.
Unfortunately, that module doesn't seem to know about the node-contenttype.tpl.php file at all. It prints the data label with plenty of unwanted space followed by the field contents.
Is it possible to write a theme that works with the printer-friendly module, some node-contenttype.print.tpl.php? Or to have a link that causes the particular content type to reload the page with a custom stylesheet called?
If anyone has a pointer in the right direction, it would be greatly appreciated.
Comments
Here's a pointer ONLY. I am
Here's a pointer ONLY. I am venturing...
1. Create a .css file only for
media "print".2. Find how you can link to that external stylesheet, by altering the code of one of the .php files - which one is it ? Good question. I hope that someone will tell us where that dynamic linking to stylesheets is to be found. When you find where it's done, alter the php programming and link LAST... (after your theme's .css) to that new .css file. Make that stylesheet the last one you link to.
3. NOW... In that new .css file use
display:"none";for all classes and id's (make up the appropriate selectors for your rules), that is for all blocks that you want gone when printing. Now, how will you know which selectors to use ? Simply do a "vew source code" on the page that you end up with, look for all block elements that you want gone. And I mean gone, not just invisible and leaving some space behind.Here's what I ended up doing
I did end up bypassing the Printer-Friendly module and editing my page.tpl.php file in three places.
* I import the printer-friendly style sheet if the variable "printme" was set in the URL:
* I display a link back to the non-printer format if you're in the the printme view.
* I display the printer-friendly link. It currently displays everywhere, including admin pages.
This, combined with the appropriate style sheet is working well.
This was working great for me...
This was working *great* for me -- until I recently updated CCK to the newest version. Now, inexplicably, it has no effect. And I *swear* that's the only thing I changed -- nothing new with the views, nothing different with the template, etc. Updated CCK, and no more functioning print links. It goes to the link (?whatever=y) but doesn't execute the things within the PHP if tags, so the stylesheet never gets loaded and everything looks like it always does...I'm really at a loss. Please let me know if you have any ideas.
Follow-up
I posted a more comprehensive description of what I did and what I'm trying to do in this post. I really do like this solution, and I'm really disappointed that I can't figure out how to make it work again.
It was the CCK upgrade
The CCK templates went from being content-[nodetype] to content_[nodetype]. So nothing to do with this at all -- it's working again, and it's beautiful. Thanks!
Can someone walk me through this?
I'm getting really desperate for this feature and I just do not understand how the above code is implemented. If someone could walk me through this, I'd greatly appreciate it.
I went into page.tpl.php, but do not know where to substitute code for the above code if that is even necessary.
ANY help is appreciated. I tried the "printable" and "page array" module and it does not work well either.
There is a 'printable' module which works with CCK
There is a 'printable' module, which works well with CCK. It is more rough than 'printer friendly', but does the trick.
The module is here: http://drupal.org/project/printable
Note: it depends on hard-to-find pagearray, which is here: http://ftp.osuosl.org/pub/drupal/files/projects/pagearray-5.x-1.x-dev.ta...
Printable CCK Views pages
The 'printable' module seems to be abandoned, and the 'print' module still doesn't handle CCK and views. Any Drupal 5 solution?
Amnon
-
Professional: Drupal Israel | Drupal Development & Consulting
Personal: Hitech Dolphin: Regain Simple Joy :)