Page 1 of 1

full page article url, logo etc in print friendly page

Posted: Mon Nov 19, 2007 8:20 pm
by ewel
Update: I amended my original post to reflect that this now works with Joomla SEF turned on, with different headers for printing and emailing, and with VisualRecommend or mXcomment swtiched on.

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.mydomain.com/index.php?optio ... =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.mydomain.com/index.php?optio ... =view&id=1
The page title ("mydomain.com - Welcome to Joomla!") and domain ("mydomain.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 widt 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":

Code: Select all

// 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.

Code: Select all

<?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).

Good luck!

Re: full page article url, logo etc in print friendly page

Posted: Thu Feb 28, 2008 11:11 am
by yerg
This tip does not work as the urls created are disfunctional

The code supplied generates urls in the popup that are screwed

Here's an example

http://www.domain.com/index.php?ndex2.p ... view&id=51

Notice the addition of ... ndex2.php?

Suggest this post is altered/edited or something cos the tip is worth more trouble than it's worth as it stands

Re: full page article url, logo etc in print friendly page

Posted: Sat Mar 01, 2008 8:12 am
by ewel
I now use Joomla 1.5 and have not implemented this yet, so I cannot go back to check.

However, re-reading the code I would not be surprised if the error originates in the second and third lines which merged together would read: "$urlparttoexplode = substr($_SERVER["REQUEST_URI"], 12);". I think this was intended to strip of the domain from the rest of the url - but does so only as long as the stripped off part has 12 characters.
The fact that your resulting url has "ndex2" and not 'index2' (note the missing first letter) would also point to a badly used count. Also, when I posted this, I pasted (and amended to hide my domain) the output I had working on my site.

Perhaps you can verify if this is the cause by changing the number. If this does prove to be the issue we can replace the third line by a more effective way to get the relevant part of the url. Seeing you are a Joomla hero you may be able to help with that.