I have a view of user data. I want to print a postcard for each one with name and address from the view on the front and other data from the view on the back. Ideally, there will four postcards per printable page, so matching up front-side data and back-side data is a challenge.

  • Listing user details is easy, yes, you can do that with the core Views module out of the box by just adding fields and then overriding templates if required. Styling that to look like a postcard is also relatively easy (depending on your css skills obviously). The only difficulty is getting it to print 4 on a single page. That'll take mid-high level css knowledge/skills. The Drupal part is pretty easy though, just list out the details you want in the postcard; the rest is styling – Clive May 4 '17 at 16:09
  • I edited this after @Clive answered to specify that there will be user data on front and back, something I hadn't really explained before. – Marshall Morrise May 10 '17 at 21:48

I solved this problem with a custom module. Total php, html, and css is 250 lines. Cards can be printed double-sided or fronts and backs separately for non-duplex printers. I prepare the view with the following code:

$view = views_get_view('postcard');
$view->preview = true;
$view->is_cacheable = false;

To access view data after the above processing, I wrote a simple getViewData() function that uses Drupal's field_get_items().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.