DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:printview

Print view

Creates a print view button using the do=export_html option. It's quite similar to the Print View Button, but it uses (action) buttons.

Changes

Template.php

Open inc/template.php. Find (line 468)

    case 'profile':
      if($conf['useacl'] && $_SERVER['REMOTE_USER'] &&
         $auth->canDo('Profile') && ($ACT!='profile')){
        print html_btn('profile',$ID,'',array('do' => 'profile'));
        return true;
      }
      return false;
    default:
      print '[unknown button type]';
      return true;
  }

and change it to

    case 'profile':
      if($conf['useacl'] && $_SERVER['REMOTE_USER'] &&
         $auth->canDo('Profile') && ($ACT!='profile')){
        print html_btn('profile',$ID,'',array('do' => 'profile'));
        return true;
      }
      return false;
    case 'print':
      tpl_link(wl($ID,'do=export_html'), $pre.$suf, 'class="action print" accesskey="p" rel="nofollow"');
      return true;
    default:
      print '[unknown button type]';
      return true;
  }

Find (line 600)

    case 'profile':
      if($conf['useacl'] && $_SERVER['REMOTE_USER'] &&
         $auth->canDo('Profile') && ($ACT!='profile')){
        tpl_link(wl($ID,'do=profile'),$pre.$lang['btn_profile'].$suf, 'class="action profile" rel="nofollow"');
        return true;
      }
      return false;
    default:
      print '[unknown link type]';
      return true;


change it to

    case 'profile':
      if($conf['useacl'] && $_SERVER['REMOTE_USER'] &&
         $auth->canDo('Profile') && ($ACT!='profile')){
        tpl_link(wl($ID,'do=profile'),$pre.$lang['btn_profile'].$suf, 'class="action profile" rel="nofollow"');
        return true;
      }
      return false;
    case 'print':
      tpl_link(wl($ID,'do=export_html'), $pre.$suf, 'class="action print" accesskey="p" rel="nofollow"');
      return true;
    default:
      print '[unknown link type]';
      return true;

Design.css

Next open /lib/tpl/default/design.css. Find “a.index” and copy the lines changing a.index into a.print. So

div.dokuwiki div.toolbox_sidebar a.index,

becomes

div.dokuwiki div.toolbox_sidebar a.index,
div.dokuwiki div.toolbox_sidebar a.print,

And

div.dokuwiki div.toolbox_sidebar a.index {
  background: transparent url(images/tool-index.png) 1px 1px no-repeat;
}

becomes

div.dokuwiki div.toolbox_sidebar a.index {
  background: transparent url(images/tool-index.png) 1px 1px no-repeat;
}
 
div.dokuwiki div.toolbox_sidebar a.print {
  background: transparent url(images/tool-print.gif) 1px 1px no-repeat;
}

Where url(images/tool-print.gif) is you print icon.

[...]

Do the same for the other instances of a.index

Main.php

Next open /lib/tpl/default/main.php and add

<?php tpl_button('print')?>

wherever you want the print icon to appear. For example change

        <?php tpl_button('edit')?>
        <?php tpl_button('history')?>

to

        <?php tpl_button('edit')?>
        <?php tpl_button('print')?>
        <?php tpl_button('history')?>

And you should see your print icon appear between the edit and the history button =)

- Marc Troost 24-10-2007

Discussion

The do=export_html option does not use the print.css when you view it on the screen so what you print out can look very different.

Using export_xhtml as a base, I added export_print to inc/actions.php under function act_export($act) This will use the print.css for print view on screen. Hopefully, someone with more programming skill can put all these together into a nice action plugin.

  // Printable View
  if($act == 'export_print'){
    global $conf;
    global $lang;
    header('Content-Type: text/html; charset=utf-8');
    ptln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
    ptln(' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
    ptln('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$conf['lang'].'"');
    ptln(' lang="'.$conf['lang'].'" dir="'.$lang['direction'].'">');
    ptln('<head>');
    ptln('  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
    ptln('  <link rel="stylesheet" media="all" type="text/css" href="/wiki/lib/exe/css.php?s=print" />');    
    ptln('  <title>'.$ID.'</title>');
    ptln('</head>');
    ptln('<body>');
    ptln('<div class="dokuwiki export">');
    print p_wiki_xhtml($ID,$REV,false);
    ptln('</div>');
    ptln('</body>');
    ptln('</html>');
    exit;
  }

- OTU 12-13-2007

tips/printview.txt · Last modified: 2013-01-23 08:16 by 217.86.192.129

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki