Hallo,
is it possible if you open a site as printversion (website.com/Unternehmen&print), and you click on a link, you stay in the print version? What I mean is thet the &print will be added automatically to all links in printversion.
Thanks in advance.
Print Link
Re: Print Link
Hi mitch,
In cmsimple/cms.php change line 420 (the line number varies between different versions) from:
to:
Christoph
Basically that is possible--however, adding &print to URLs that are not links to CMSimple pages won't make sense, and may be even wrong. If the latter is not of concern, the solution is rather simple. Just add the following function to cmsimple/userfuncs.php:mitch wrote:What I mean is thet the &print will be added automatically to all links in printversion.
Code: Select all
function makePrintLinks($content)
{
return preg_replace('/<a([^>]+)href="([^"]*)"/', '<a$1href="$2&print"', $content);
}
Code: Select all
content(), '</body>' . "\n" . '</html>' . "\n";
Code: Select all
makePrintLinks(content()), '</body>' . "\n" . '</html>' . "\n";
Christoph M. Becker – Plugins for CMSimple_XH
Re: Print Link
Thanks a lot for your efficient answer. Can some pages be defined to be excluded?cmb wrote:Hi mitch,
Basically that is possible--however, adding &print to URLs that are not links to CMSimple pages won't make sense, and may be even wrong. If the latter is not of concern, the solution is rather simple. Just add the following function to cmsimple/userfuncs.php:mitch wrote:What I mean is thet the &print will be added automatically to all links in printversion.In cmsimple/cms.php change line 420 (the line number varies between different versions) from:Code: Select all
function makePrintLinks($content) { return preg_replace('/<a([^>]+)href="([^"]*)"/', '<a$1href="$2&print"', $content); }
to:Code: Select all
content(), '</body>' . "\n" . '</html>' . "\n";
ChristophCode: Select all
makePrintLinks(content()), '</body>' . "\n" . '</html>' . "\n";
Re: Print Link
Well, you can split function makePrintLinks() in two parts and treat links to these pages differently:mitch wrote:Can some pages be defined to be excluded?
Code: Select all
function makePrintLink($matches)
{
$url = $matches[2];
if (strpos($url, 'http') === 0) {
// let "external" links alone
} elseif ($url == '?No_print_view') {
// let certain links alone
} else {
// append "&print" to all others
$url = $url . '&print';
}
return '<a' . $matches[1] . 'href="' . $url . '"';
}
function makePrintLinks($content)
{
return preg_replace_callback('/<a([^>]+)href="([^"]*)"/', 'makePrintLink', $content);
}
Christoph M. Becker – Plugins for CMSimple_XH
Re: Print Link
Thaks a lot exactly what I'm searching. I will try that...
Re: Print Link
I have suggested to implement a general solution for CMSimple_XH 1.6.
Christoph M. Becker – Plugins for CMSimple_XH