Page 1 of 1

HOWTO: Stop robots indexing printer-friendly versions of pages

Posted: Sat Oct 22, 2005 10:10 pm
by martin42
In case you missed it, there's a cool CMSMS tag called {printer} that makes a link to a printer-friendly version of your web page. I use the following in my Template's Content area, a few blank lines after the content of the page:
 

Code: Select all

<small>Printer-friendly version: {print showbutton="true"}</small>
Now, you don't want Google & co indexing the printer-friendly version of each page.  We can stop this by adding a meta tag to the of such pages:

Code: Select all

<meta name="robots" content="noindex"></meta>
We can do this automatically with a one-line patch to content.functions.php

Code: Select all

diff content.functions.php.ORIG content.functions.php
150c150
<                                       $tpl_source = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'."\n".'<__html><head><title>{title}</title>{stylesheet}{literal}<style type="text/css" media="print">#back {display: none;}</style>{/literal}</head></__body style="background-color: white; color: black; background-image: none;"><form action="index.php?page='.$tpl_name.'" method="post"><input type="submit" value="Go Back"></form>{content}<__body></__html>';
---
>                                       $tpl_source = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'."\n".'<__html><head><title>{title}</title><meta name="robots" content="noindex"></meta>{stylesheet}{literal}<style type="text/css" media="print">#back {display: none;}</style>{/literal}</head></__body style="background-color: white; color: black; background-image: none;"><form action="index.php?page='.$tpl_name.'" method="post"><input type="submit" value="Go Back"></form>{content}<__body></__html>';
Hope this is useful.

Re: HOWTO: Stop robots indexing printer-friendly versions of pages

Posted: Sun Oct 23, 2005 1:31 am
by Ted
Nice simple patch.  I've just committed it.

Re: HOWTO: Stop robots indexing printer-friendly versions of pages

Posted: Sun Oct 23, 2005 5:25 am
by martin42
Wow, that was quick!

Thanks Wishy.

Re: HOWTO: Stop robots indexing printer-friendly versions of pages

Posted: Wed Nov 02, 2005 7:00 am
by trick
Another thing you could possibly do on the print page is to redirect any external referers to the original page.

Re: HOWTO: Stop robots indexing printer-friendly versions of pages

Posted: Thu Mar 16, 2006 10:50 am
by mustis
Printer-friendly version: {print showbutton="true"}

Why does this tag always show the main page inn printer friendly??

If i put this tag in page 3 it always will print page 1

Please help!!