Views 2 Support?

skyredwang - December 2, 2008 - 17:33
Project:Printer, e-mail and PDF versions
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

I am just wondering if by any chance you are going to add Views 2 support, so A nice view list or table can be printed out? thanks a lot

#1

jcnventura - December 2, 2008 - 21:02
Status:active» postponed

Hi,

I don't think that Views support will happen in the near future.. I need either to feel the need for it myself, or someone that is really interested ($$$) to sponsor that project.

João

#2

skyredwang - December 2, 2008 - 21:17

That's reasonable. How about a "action" plugin, let's say "print", which print out the node with given nid. In this way, people can use "Views Bulk Operations" module to bulk-print a Views 2 list/table

#3

jcnventura - December 3, 2008 - 00:16

That looks a lot like a wishlist for the views support. I forgot to mention option 3: someone else contribute a patch :)

Now seriously, there's no need of a weird action there.. Just calling the URL print/PATH will generate the printer-friendly version of any path under Drupal.. However, since I don't know the technical details of what you're asking, I have no idea if that info helps or not.

João

#4

btopro - February 3, 2009 - 04:23

You can add the pdf stuff pretty easily by creating the correct view.tpl.php and modifying it. I did this recently by adding the nid field to the view and then detecting for it and adding in a l(t('pdf'),'print/'. $nid);

Save this dude some time via this easy way of doing the same thing :)

#5

markku - February 9, 2009 - 21:50

Can you expand on that a bit more? Maybe paste your code and a bit of how-to. As far as I can see it, this is a top priority to have views integration, one way or another.

#6

btopro - February 9, 2009 - 22:05

Sure can. You just create a well-formatted template file in your theme that's named correctly for the view it should be associated with...

So, I created a file called views-view--print-activation-codes.tpl.php (cause my view is called print-activation-codes)

and put this in it

<?php
// $Id: views-view-table.tpl.php,v 1.6 2008/06/25 22:05:11 merlinofchaos Exp $
/**
* @file views-view-table.tpl.php
* Template to display a view as a table.
*
* - $title : The title of this group of rows.  May be empty.
* - $header: An array of header labels keyed by field id.
* - $fields: An array of CSS IDs to use for each field id.
* - $class: A class or classes to apply to the table, based on settings.
* - $rows: An array of row items. Each row is an array of content
*   keyed by field ID.
* @ingroup views_templates
*/
?>

<?php
if (!empty($title)) :
?>

<?php
print $title;
?>

<?php
endif;
?>

<?php
foreach ($header as $field => $label):
?>

<?php
print $label;
?>

<?php
endforeach;
?>

<?php
foreach ($rows as $count => $row):
?>

<?php
foreach ($row as $field => $content):
?>

<?php

           
if ($field == 'nid') {
              print
l(t('Print'),'print_activation_codes/'. $content);
            }
            else {
              print
$content;
            }
           
?>

<?php
endforeach;
?>

<?php
endforeach;
?>

The part that I changed from the file as Views2 looks to generate is this

<?php

           
if ($field == 'nid') {
              print
l(t('Print'),'print_activation_codes/'. $content);
            }
            else {
              print
$content;
            }
           
?>

So what I did is include the nid in the display and then I trap for it and print a link to the print view (or at least I did it to some other link but you could make it go to the print link path). If it's not the nid it prints the table-cell as it normally should.

#7

jcnventura - May 4, 2009 - 15:24

Another item for the views support requirements (from #439458: Integration with Node Hierarchy):

Given a list of nodes in a view, provide the print-friendly page containing all of those pages.

#8

ncameron - June 10, 2009 - 07:33

There are a couple of workarounds which enable you to 'nudge' the theming in the right direction, although not gain complete control:

1) If you include your main CSS file in print.tpl.php most of the formatting still works on the print page, but with the same simple layout.

2)

<?php
print arg(0)
?>
returns the name of the view, so you could use this in an if() statement to include a CSS file specific to each view. This could be used for hiding (display:none) certain things or adjusting the page width etc.

Cheers,

Neil

#9

ncameron - June 10, 2009 - 08:40

You can also use a request_uri() to detect if it is print, pdf or email and then include a stylesheet accordingly e.g.

<?php
  $uri
= request_uri();
  if(
strpos($uri, '?q=printpdf/')):
?>


  <link href="/sites/all/themes/gta/gta-pdf.css" media="all" rel="stylesheet" type="text/css">

<?php endif;?>

#10

akolahi - September 17, 2009 - 00:38

You can easily pdf any view by just sticking printpdf/ in front of the view's url. i.e. www.example.com/printpdf/viewpage

you can then make a block with the above url, and have it show up on the view's page only that says click here for PDF version

that's all. simple effective fix to get a pdf of most views.

#11

TomSherlock - October 1, 2009 - 18:27

@akolahi,
how do get the pdf version link to show up on a view? At the moment i can only get it to show on nodes.

Your solution sounds like a quick and easy fix for printing views.

Ok. I just reread your suggestions. It sounds like you hard code the URL into the block and when placing the block on the view you include text to the effect of 'click here for pdf version'. Is this text IN the block or the TITLE of the block and does it matter?

Thanks

#12

TomSherlock - October 1, 2009 - 18:42

Either i'm doing something wrong or my theme is broken. The block does not show on my view.

#13

TomSherlock - October 1, 2009 - 20:18

@akolahi,

I couldn't get the block to show in a view, so i tried including a link in the view's footer. The link shows. But adding printpdf before the view results in a page not found.

#14

j4 - October 2, 2009 - 12:13

Did you install the special dompdf tool? See http://drupal.org/node/306882
I had a similar problem and that is solved now. I still have issues with printing a pdf of a view with multiple columns (they all get printed one on top of the other!), but you should be able to solve your problem with help from that page.

Warm regards
Jaya

#15

akolahi - October 13, 2009 - 02:48

TomSherlock,

if you place the link in a block, you need to go to the block admin page to make sure the block is visible on the particular view's page. Basically you want to the block to only show on that page and you need to tell the block the url of the view you would like for it to show up on.

Yes, I have the dompdf.

#16

mnm_mike - October 29, 2009 - 19:23

Good chance I'm interpretting this incorrectly, but I hope this is the right place to ask this:

I've installed the module and it looks and works great on content added from content types.

I've got a standard view that generates content based on fields and filters, nothing to out of the ordinary. On these pages, the printer-friendly version does not display.

In the option: Show link in system (non-content) pages: I have checked "Show on every page except the listed pages." I have nothing listed in the exceptions...shouln't it be showing up on the pages that are generated with views?

Am I overlooking something? Appreciate any help.

- I was a drupal newbie a few months ago then got put on another project, now just put back on this so if this is the wrong forum...I'm catching back up. Thanks

#17

jcnventura - October 29, 2009 - 22:17

Yes, the links should be showing in all the views pages now.

 
 

Drupal is a registered trademark of Dries Buytaert.