Actions

Difference between revisions of "Full page article, URL, logo etc. in printer friendly page"

From Joomla! Documentation

m (Changed category)
m (Oops! Wrong version.)
Line 65: Line 65:
 
Attached is a .rar file with my index2 file which you can download to upload to your Joomla installation together with a logo (but first backup your existing file and be careful if you use SEF urls).
 
Attached is a .rar file with my index2 file which you can download to upload to your Joomla installation together with a logo (but first backup your existing file and be careful if you use SEF urls).
  
[[Category:Tips and tricks 1.5]]
+
[[Category:Tips and tricks 1.0]]

Revision as of 10:30, 14 July 2008

The Joomla built-in printer and email friendly page has a major flaw in that some important information is missing which makes it less user-friendly and marketing unfriendly. The missing information is: 1) a logo; 2) the name of the site; 3) the domain; 4) the URL where the visitor clicked the Joomla print button; and 5) a minimal claim to copyrights. In short, a print-out of a page will not help people return to the website.

Having searched all over these forums as well as the web I discovered that there is no ready solution for this yet. Therefore I set out to solve it myself. I soon discovered that the solution requires a little bit of code, and I have no experience at all in writing PHP, but after some research I managed to produce something that works, at least for me.

It is not a perfect solution; I do not know if it works in Joomla 1.5, I have no idea if there are inadvertent effects in other Joomla installations than mine, and it would be far nicer to have this a as a mambot. But it is a start and everyone is invited to add improvements to it.

Just to clarify and avoid wrong impressions or expectations; I am a lawyer not a developer and while I am glad to be able to give something back to the Joomla community I am not in a position to provide you any support. I am just pleased I managed to do this and thought it would be good to share my solution.

So, if you agree that this is as is, without support and without any warranty and what have you in a full disclaimer, then feel free to use it and please post any improvements or suggestions you have here.

My simple solution is adding a few lines of php and html which display as follows at the top in the printer-friendly popup page:

 [my logo image]
 Printer-friendly version of: mydomain.com - Welcome to Joomla! (© 2007 mydomain.com)
 Full page url: http://www.example.com/index.php?option=com_content&task=view&id=1
 Right-click to print this page

And at the top of the email a friend popup page:

 [my logo image]
 Emailing: mydomain.com - Welcome to Joomla! (© 2007 mydomain.com)
 Full page url: http://www.example.com/index.php?option=com_content&task=view&id=1

The page title ("example.com - Welcome to Joomla!") and domain ("example.com") are links to the full version of the article and the domain, respectively, and the url of the full article page is also linked. In both the url and the link I skipped the 'Itemid' bit as it is not clear to me that it is necessary.

The image is set to 'logo.gif' in the images folder in the Joomla root, where you can upload your own image. If your imaged is not already properly sized to your taste you may have to set the width and height.

To do this I added these lines of php to the 'index2.php' file in the Joomla root folder, just above the comment that reads "// start basic HTML":

// taking current url and creating url of full article
$articleprintversionurl = $_SERVER["REQUEST_URI"]; // getting part of the url to be edited
$urlparttoexplode = substr($articleprintversionurl, 12);  // create part of url to be exploded
if ( $option == 'com_visualrecommend' ) {
  list($optionpartofurl, $taskpartofurl, $compartofurl, $idpartofurl, $Itemidpartofurl) = explode("&", $urlparttoexplode);
  $articlefullversionurl = "http://www." . $mosConfig_sitename . "/index.php?option=com_content&task=view&" . $idpartofurl;
  // building up full   article url
} else {
  list($optionpartofurl, $taskpartofurl, $idpartofurl, $poppartofurl, $pagepartofurl, $Itemidpartofurl) = explode("&", $urlparttoexplode);
  $articlefullversionurl = "http://www." . $mosConfig_sitename . "/index.php?" . $optionpartofurl . "&" . $taskpartofurl . "&" . $idpartofurl;
  // building up full article url
}
if ( $task == 'emailform' ||  $option == 'com_visualrecommend' ) {
  $addedheadertext = "<p style=\"margin-left:3px;\"><img src=\"" . $mosConfig_live_site . "/images/logo.gif\" border=\"0\" width=\"165\"
  height=\"87\" alt=\"logo\"><br><br><b>Emailing: <a href=\"" . $articlefullversionurl . "\">" .
  $mainframe->getPageTitle() . "</a> (© " .
  $year . " <a href=\"http://" . $mosConfig_sitename . "\">".$mosConfig_sitename . "</a>)<br>Full page url: <a href=\"" .
  $articlefullversionurl . "\">" . $articlefullversionurl . "</a></b><br><br></p>";
} else {
  $addedheadertext = "<p style='margin-left:3px;'><img src='" . $mosConfig_live_site . "/images/logo.gif' border='0' width='165' height='87'
  alt='logo'><br /><br><b>Printer-friendly version of: <a href='" . $articlefullversionurl . "'>" .
  $mainframe->getPageTitle() . "</a>
  (© " . $year . " <a href='http://" . $mosConfig_sitename . "'>" . $mosConfig_sitename . "</a>)<br>Full page url: <a href='" .
  $articlefullversionurl . "'>" . $articlefullversionurl . "</a><br><i>Right-click to print this page</i><
  /b><br><br></p>";
}

Then I inserted the following in the html between "" and "" towards the end of the file.

<?php echo $addedheadertext ?>

Attached is a .rar file with my index2 file which you can download to upload to your Joomla installation together with a logo (but first backup your existing file and be careful if you use SEF urls).