I've set PDF file name to:
[title] - [site-name] - [mod-yyyy]-[mod-mm]-[mod-dd]
For the front page (where more node summaries are published), [mod-yyyy], [mod-mm] and [mod-dd] are obviously not set, and the PDF file name becomes something like:
Example Title - www.example.com - [mod-yyyy]-[mod-mm]-[mod-dd].pdf
This looks not only ugly, but also not very professional. It would therfore be good the name composition to work in a bit more clever way, for example to skip some parts if all components of it (or, if any component) are missing (not set). In my particular example, I would like to check if [mod-yyyy] is not available, and skip the complete " - [mod-yyyy]-[mod-mm]-[mod-dd]" part in such a case.
As it is probably not easy to hard code all possible situations to suit any needs, a possibility to add a PHP code instead of just a text field (and, then replace tags as [mod-yyyy] with appropriate variables before processing it...) would be an optimal solution (altough not very user-friendly for people without any programming skills...).
So, in my case, something like:
"[title] - [site-name]" . !isset([mod-yyyy]) ? " - [mod-yyyy]-[mod-mm]-[mod-dd]" : ""
could be used...
Or, use conditional fields (one field for condition and other 2 for TRUE / FALSE case) to be concatenated, to get the complex file name. This would make it a bit easier for users not know much about PHP (altough any site admin should probably be able to make a conditional sentence in PHP).
Comment | File | Size | Author |
---|---|---|---|
#25 | patch_commit_d46a76b69ee1.patch | 1012 bytes | bachbach |
#13 | clear_unused_tokens-890632-13-D6.patch | 1.43 KB | pillarsdotnet |
#11 | token_replace_clear_option-890632-11.patch | 1.36 KB | pillarsdotnet |
#7 | print.patch | 762 bytes | Ashraf Amayreh |
Comments
Comment #1
jcnventura CreditAttribution: jcnventura commentedThat's all handled by the token module. Of course, those tokens are only set for nodes... I will try to filter everything between [] for non-nodes..
Comment #2
Apfel007 CreditAttribution: Apfel007 commentedsubscribe
Comment #3
Apfel007 CreditAttribution: Apfel007 commentedany ideas on that?
How could be manage this issue?
Comment #4
Apfel007 CreditAttribution: Apfel007 commentedany news?
Comment #5
Ashraf Amayreh CreditAttribution: Ashraf Amayreh commentedI think this amounts to a bug, as far as I can tell, this also fails (this is a webform generated URL to generate PDFs from submissions):
http://www.example.com/printpdf/131/submission/99
This also has no access to node variables at all. What I'm a little unsure about is weather this is a token or print module issue. If someone can point me to where this is handled I'll be glad to submit a patch.
Comment #6
pillarsdotnet CreditAttribution: pillarsdotnet commentedI'd vote for "token issue" but maybe there is someone out there who wants square-brackets in their otherwise token-replaced strings. See for example #733192: Tokens enclosed in [ ] are not recognized
Comment #7
Ashraf Amayreh CreditAttribution: Ashraf Amayreh commentedWell, it turns out this one in particular is a print module issue.
The node, which is passed to tokens was undefined. All I needed was to load it before the call to token_replace(). Patch attached.
Comment #8
Ashraf Amayreh CreditAttribution: Ashraf Amayreh commentedOh, I think it's wrong to assign it to myself... unassigning...
Comment #9
jcnventura CreditAttribution: jcnventura commentedI need to see this better.. If this were the solution, tokens would never have worked.
Comment #10
LUTi CreditAttribution: LUTi commentedPatch in #7 doesn't seem to resolve my issue (tested with the front page). And, yes - I've cleaned the cache (Drupal and browser), if it matters.
Comment #11
pillarsdotnet CreditAttribution: pillarsdotnet commentedCalls to token_replace() should be setting the clear option.
Patch attached.
Comment #12
jcnventura CreditAttribution: jcnventura commented@pillarsdotnet: that would be for the D7 version right?
Comment #13
pillarsdotnet CreditAttribution: pillarsdotnet commentedYes, but the same syntax is used in the 6.x-1.x version of the token module.
6.x-compatible patch attached.
Comment #14
LUTi CreditAttribution: LUTi commentedUnfortunately, patch #13 doesn't seem to resolve my issue either (at least at the frontpage I've tested).
Comment #15
jcnventura CreditAttribution: jcnventura commented@LUTi: I think you have to be using the current dev of token module for that patch to be effective (I still haven't tested this)
Comment #16
LUTi CreditAttribution: LUTi commentedI've installed print -dev and token -dev version, but now I am even without a [title] (it is replaced by an empty string). I've tried also [page-title] and [current-page-title] - they are both replaced by "PrinterFriendly PDF" instead of the original page title.
Reverting token back to 1.15 didn't resolve anything, so I can only blame the new -dev version of PrintPDF for even worse behavior. Fortunately, my production site is still using the old configuration.
Comment #17
2ndmile CreditAttribution: 2ndmile commentedI am getting blank file names when using [title] as well. Any progress on this issue?
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedsame problem of #17, any progress about this issue?
Comment #19
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #20
jcnventura CreditAttribution: jcnventura commentedComment #21
Anonymous (not verified) CreditAttribution: Anonymous commentedI updated the print module to last dev but the issue is still present
[site-name]_[title]_[mod-small]_by_[author-name]
gives
site-name_title_mod-small_by_author-name
I also tryed to apply patch #13, but it doesn't work
Comment #22
jcnventura CreditAttribution: jcnventura commentedThis problem was introduced as part of splitting the print_pdf_controller() function in order to provide an API for PDF generation (#1044138: Allow print_pdf to be called from another module and return PDF as a string (eg to attach a PDF with mimemail)).
I've fixed this in D7 and D6.
Comment #24
jvieille CreditAttribution: jvieille commentedNot sure it is the same issue, but using print-6.x-1.14 or the last dev generates a pdf name like this
book_export_html_165.pdf
where 165 is the node ID
Note:
- pdf file name is set to default "[site-name] - [title] - [mod-yyyy]-[mod-mm]-[mod-dd]"
- using tcpdf
Comment #25
bachbach CreditAttribution: bachbach commentedhere is my "not super clean" solution.
on print_pdf.pages.inc L35, replace
by
Comment #26
jvieille CreditAttribution: jvieille commentedpatch #25 works fine.
18 months issue, please commit!
Thanks
Comment #27
bfdi533 CreditAttribution: bfdi533 commentedThis patch works for me as well. Please commit.
Comment #28
kholloway CreditAttribution: kholloway commentedFYI, Patch #25 worked for me as well using the Drupal 6 latest Dev version.