Suggested Feature - Article PDF File Name
Posted: 21 Aug 2009, 20:28
Currently, the plgSystemPhocaPDFContent plug-in defaults to a PDF filename of 'Phoca PDF' if the plug-in parameter 'PDF Name:' (as set in the back-end component) is left blank. This is set on line 125 of the \plugins\system\phocapdfcontent.php file: While this works I would suggest that it would make more sense for the $content->pdf_name to be set to the title of the article itself IF the 'PDF Name:' parameter is left blank. i.e. An article titled 'My Favorite Things' would get a $content->pdf_name of something like 'my-favorite-things.pdf'. In my case I'd prefer users to download PDF documents with file names that make it somewhat clear (for later recall) what it is.
An additional parameter of 'Use Article Title for File Name' could be included in the backed if that sort of default behavior is not to Phoca's liking. FWIW, I was able to implement this behavior with a simple code change (use at your own risk):
File: \libraries\joomla\document\phocapdf\phocapdf.php
Line: 142
Change:To:NOTE: I've also change the setName function in the \libraries\joomla\document\phocapdf\phocapdf.php to: so as to attempt to eliminate any wacky characters that might be in the article Title.
While this may not be the absolute best way to go about it (you guys know your code much better than I do) I think implementing something like this would be quite easy and potentially improve the product. Thanks for listening.
PS: Almost forget: Sticking on a '.pdf' file extension to the $content->pdf_name probably wouldn't hurt as well but not sure it's absolutely necessary.
Code: Select all
$content->pdf_name = $pluginP->get('pdf_name', 'Phoca PDF');
An additional parameter of 'Use Article Title for File Name' could be included in the backed if that sort of default behavior is not to Phoca's liking. FWIW, I was able to implement this behavior with a simple code change (use at your own risk):
File: \libraries\joomla\document\phocapdf\phocapdf.php
Line: 142
Change:
Code: Select all
switch ($option) {
case 'com_content':
$results = $dispatcher->trigger('onBeforeDisplayPDFContent', array (&$pdf, &$content, &$this));
break;
Code: Select all
switch ($option) {
case 'com_content':
$results = $dispatcher->trigger('onBeforeDisplayPDFContent', array (&$pdf, &$content, &$this));
if($content->pdf_name == 'Phoca PDF') $content->pdf_name = $this->getName();
break;
Code: Select all
function setName($name = 'Phoca') {
$this->_name = JString::strtolower(JFile::makeSafe(JString::str_ireplace(' ', '-', $name)));
}
While this may not be the absolute best way to go about it (you guys know your code much better than I do) I think implementing something like this would be quite easy and potentially improve the product. Thanks for listening.
PS: Almost forget: Sticking on a '.pdf' file extension to the $content->pdf_name probably wouldn't hurt as well but not sure it's absolutely necessary.