3

I'd like to dynamically create a view for each of my content types/items, and then export that View's data to PDF format.

My (Drupal 7) website tracks mileage, gas usage, engine usage, and other items for a fleet of cars. Let's say I want to run a report on Car A. I'd like to have a single view that could pull in only the information for Car A when I click a link on Car A's content page. Then, if I click a link on Car B's page, it would pull in only the information for Car B. The same would be true for Engine A, Engine B, etc. The purpose would be to see a snapshot of the usage of that car, engine, etc.

I use the Entity Reference module to link individual usage content items to each of the "master" content items (cars, engines, etc). The Usage content items have the following fields: the VIN/serial number of the car/engine (which links the usage content item back to the car/engine), miles driven since last visit, gas remaining since last visit, etc. These usage items are the most important thing for this usage report. There will be other fields from the Car, Engine, etc (such as the color of the car, starting mileage, etc) that will appear on the report, but those are really just information; the usage items are key.

Is all of this possible with Views out of the box? Or would I need an additional module to accomplish this?

Thanks!

1

I was able to get the output that I needed by using the Reference module and the Viewfield module.

  1. Created Content type A and content types B, C, and D. B, C, and D are all associated with Content type A via Reference fields.

  2. Created contextual/relationshipped views for B, C, and D, relating it to the title field of Content Type A.

  3. Created a Viewfield on Content Type A for each of the sub-content types (B, C, and D).

  4. Created a View for Content Type A, contextualized with Content:Title, and added the Viewfields to this new View (using reverse relationships with the node referenced field). I then added a PDF Page view using Views PDF, and that did the trick!

I can provide more detail if needed. Just let me know...

0

Views can do the basic reporting with some tinkering.

Look into these possible modules for outputting a PDF of a report view:

  1. Views PDF
  2. Print
  • Thanks, tenken. I am playing around with Views PDF already, and it seems to be the solution for me. Do you have any input on how I can build a view dynamically, as I described? Basically, pulling in info/content based on data in Entity Reference fields. – hockey2112 Dec 7 '12 at 16:31
  • you just add a relation to the view on the referenced entity. Its under the "Relations" area of the far right column for a views edit display. – tenken Dec 7 '12 at 17:10
  • I added a relationship for Entity Reference: Car serial number the engine is assigned to. I created the View as a block, and added that block to the Content area. When I visit the car with serial number ABC123, the block shows me the engine for serial ABC123, as well as all the other engines for the other cars. So it's apparently not requiring the relationship to the Content entity referenced from that car serial number entity field, even though I have that "Required" box checked. I'm sure I'm doing something wrong, but I'm not sure what. Any ideas on what I might be missing? – hockey2112 Dec 7 '12 at 18:06
  • sorry. i'm not gonna help you debug a view much. A Relation is to another piece of content in Views. You could use a Filter (on a related field of the content) to limit what your showing. I suggest you go on IRC or look for Views tutorials. – tenken Dec 7 '12 at 19:01
  • tenken, would you be interested in taking on some of these tasks as a paid project? I feel like I am at the end of the line with my capabilities to get this (and a few other pieces of related functionality) to work. Please let me know, and I can provide you with my contact info. Thanks! – hockey2112 Dec 8 '12 at 0:45

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.