Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi there,
I try to give a pdf via token the sitename as filename. This is actually not working in my case. It get's only the path name as name. My PDF is created out of a view. Could that be the reason?
Is the token based naming only working for single nodes?
Cheers Apfel007
Comments
Comment #1
Apfel007 CreditAttribution: Apfel007 commentedany hints?
Comment #2
jcnventura CreditAttribution: jcnventura commentedYes. The token_replace() function only allows further tokens, if there's a type. In this case, I use the node type.
It should still work for the sitename when it's not a node however... I'll need to investigate further.
Comment #3
siliconmeadow CreditAttribution: siliconmeadow commentedI wonder if this is a related problem to one that I now have. Let me explain, and if necessary I can open a separate issue.
printpdf/book/export/html/55437
to generate the filename (book_export_html_55437.pdf
), instead of using the tokens specified in the form at/admin/settings/print/pdf
in the edit-print-pdf-filename field. In essence, it's using the defaults;I've spent some time with Netbeans stepping through the code but I can't seem to see when $pdf_filename is generated and the token module is ignored. I'll continue looking but any advice would be gratefully received.
Cheers,
Richard
Comment #4
jcnventura CreditAttribution: jcnventura commentedI've committed to dev a fix that tries to use the global tokens when it's not a node.. However, if the filename template uses node-specific tokens, it will still fallback on the path-based filename.
@Apfel007: Indeed, when it's not a node, it didn't even try to use non-node tokens..
@siliconmeadow: the change betwen 6.x-1.12 and 6.x-1.13 was introduced by the backport of the fix for #1235842: Notice: Undefined variable: node in print_pdf_controller(). This is actually a good fix, as a node was being passed to token_replace when there was no node..
Comment #5
siliconmeadow CreditAttribution: siliconmeadow commentedThanks jcventura. Today I'll give it a spin. I'd like to be able to have selections for different file name conventions for different node types, in the way pathauto works. Sounds like topic branch for me to work on. I hope I can contribute something back from it soon. I suspect I may also have to do something about paths like 'printpdf/book/export/html/55437'?
Do you ever use the 'Needs review' status?
Comment #6
jcnventura CreditAttribution: jcnventura commentedYes, I love the needs review.. It's my list of user-contrib patches to look at.. And 'needs work' is those that I already looked at, and could be improved. RTBC is the complicated one, it's used so rarely, that I forget patches placed there :)
The book/export/html path is using the book module's hierarchy-expansion routines. That one actually has a node (the point of origin of the book traversal), so you shouldn't need to do anything there.
If you're going to work on that, leave this issue as is, and provide a patch in #377550: Default PDF Filenames by Type?