For the pages that aren't node pages. Drupal can't replace the tokens in "PDF File Name" in this case.

CommentFileSizeAuthor
print_pdf_alter.patch508 bytesjorisdejong

Comments

jcnventura’s picture

Are you using the latest dev? The fix for #1543004: PDF filename with token solved this in part, as long as the configured filename doesn't include node-specific tokens.

rudiedirkx’s picture

Status: Needs review » Reviewed & tested by the community

I've experienced this as well. I've fixed it with a drupal_alter too. Perfect solution IMO. Last, absolute control over the filename, separate from tokens. Maybe the filename comes from something programmatic that you can fetch from the node or something else from $path. This allows absolute control.

One drupal_alter is cheap. Do it =)

I had solved the issue the exact same way, so it's reviewed. (I don't know if it'll patch though.)

jcnventura’s picture

Status: Reviewed & tested by the community » Needs work

The $path variable may be empty and it would be nice to use $node object, if that's available..

rudiedirkx’s picture

If the path is a node path, you can get the node object the way print_pdf does it, or better even: with menu_get_object. There's only 1 constant at all times: $path. Not any entity object and even less likeky a node.

Only passing a node object definitely isn't enough. A (context) assoc array with 'node' and 'path' might be good as 3rd arg to drupal_alter. I'd be (more) content with just $path.

I don't see how $path would ever be empty..? Every page has a URI. The front page too. Views too. Etc.

jcnventura’s picture

The way the module works, it's either called with path (non-nodes) or with a node.. In the latter case, path is empty.

jcnventura’s picture

Status: Needs work » Fixed

Disregard my last comment.. The only way for path to be empty is when calling the module to print the site's frontpage.

Taking that into account, I've committed the patch by jorisdejong to the devs.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.