print

26 Май 2008
Опубликовано VladSavitsky

Описание модуля

Полное название: Printer-friendly Pages
Проект начат: November 2, 2004

Описание с сайта

This module allows you to generate printer friendly versions of any node by navigating to www.example.com/print/nid, where nid is the node id of content to render.

A link is inserted in the each node (configurable in the content type settings), that opens a version of the page with no sidebars, search boxes, navigation pages, etc.

The 6.x version for Drupal 6 includes support for generating a PDF version also via the print_pdf module. Please follow the instructions in the INSTALL.txt carefully. PDF support is not usable out of the box. You must install a third-party tool!

By editing the default print.css (or specifying you own CSS file) or the print.tpl.php files, it is possible to change the look of the output page to suit your taste. For a more fine-grained customization, it is possible to use a print.node-type.tpl.php file located in either the current theme or the module directory.

Установка

Decompress the print-n.x-n.n.tar.gz file into your Drupal modules
directory (usually sites/all/modules, see http://drupal.org/node/176044 for
more information).

Enable the print module: Administer > Site building > Modules
(admin/build/modules)

PDF TOOL

The print_pdf module requires the use of an external PDF generation tool.
The currently supported tools are dompdf and TCPDF.

dompdf support:

The dompdf tool produces results that are more faithful to the HTML
printer-friendly page.

1. Download dompdf from http://sourceforge.net/projects/dompdf/
2. Extract the contents of the downloaded package into the print module
directory (usually sites/all/modules/print)
3. Edit dompdf_config.inc.php to fit your installation.
4. Grant write access to the lib/fonts directory to your webserver user.
5. If you're using dompdf-0.5.1, delete the dompdf.php file as it contains
a security vulnerability
6. Check http://www.digitaljunkies.ca/dompdf/ for further information.

DOMPDF utf-8 support - обсуждение разных библиотек для формирования PDF и поддержки в них UTF-8. Пишут, что DOMPDF имеет проблемы с Юникодом с 2006 года, но лучше всех других работает с HTML, так как работает с DOM.

TCPDF support:

TCPDF seems to be more actively developed than dompdf, but it's support
for CSS is considerably worse.

1. Download TCPDF from http://sourceforge.net/projects/tcpdf/
2. Extract the contents of the downloaded package into the print module
directory (usually sites/all/modules/print)
3. Edit the config/tcpdf_config.php file to fit your installation.
4. Check http://tcpdf.sourceforge.net/ for further information.

UPDATE

When updating from a previous version, just remove the print directory and
follow the instructions above. Make sure that you backup any costumization
to the print.tpl.php and print.css files.

Настройка

Права доступа

Administer > User management > Access control (admin/user/access)

  • access print: Enable access to the PF page and display of the PF link in other pages. (default: disabled)
  • administer print: Enable access to the module settings page. (default: disabled)

Настройка модуля

Administer > Site configuration > Printer-friendly (admin/settings/print)

- There are several settings that can be configured in the following places:

Administer › Site building › Modules (admin/build/modules)
Enable or disable the module. (default: disabled)

Administer › User management › Access control (admin/user/access)
Under print module:
access print: Enable access to the PF page and display of the PF link in
other pages. (default: disabled)
administer print: Enable access to the module settings page. (default:
disabled)

Administer › Content management › Content types (admin/content/types)
For each content type it is possible to enable or disable the PF link
via the "Show printer-friendly version link" checkbox. (default:
enabled)

Administer › Content management › Comments › Settings (admin/content/comment/settings)
It is possible to enabled or disable the PF link in individual comments
via the "Show printer-friendly version link in individual comments"
checkbox. (default: disabled)

Administer › Site configuration › Printer-friendly (admin/settings/print)
This is where all the module-specific configuration options can be set.

- To modify the template of printer friendly pages, simply edit the
print.tpl.php or the print.css files found in this directory.

- It is possible to set per-content-type and/or theme-specific templates
which are searched for in the following order:
1. print.node-__type__.tpl.php in the theme directory
2. print.node-__type__.tpl.php in the module directory
3. print.tpl.php in the theme directory
4. print.tpl.php in the module directory (supplied by the module)

API

The following function is available to content developers that prefer to
place the printer-friendly link in a custom location. It is advisable to
disable the regular Printer-friendly link so that it is not shown in both
locations.

Calling the function like this:

  print_insert_link()

will return the HTML for a link pointing to a Printer-friendly version of
the current page.

It is also possible to specify the link to the page yourself:

  print_insert_link("print/42")

will return the HTML pointing to the printer-friendly version of node 42.

THEMEABLE FUNCTIONS

The following themeable functions are defined:

theme_print_format_link()
Returns an array of formatted attributes for the Printer-friendly link.

theme_print_text
Returns an array of costumized text strings used in the printer-friendly
page.

MORE INFORMATION

За дополнительной информацией обращайтесь на страницу документации модуля: http://drupal.org/node/190171

Поисковые роботы

Even though it is possible to set per-page robots settings, the following
can be placed in your robots.txt file after the User-agent line to prevent
search engines from even asking for the page:

Disallow: /print/

Also, for updates from older versions (<=4.7.x-1.0 and <=5.x-1.2) which used
node/nnn/print instead of print/nnn, the following lines can prevent
requests from Google for the obsolete print URLs:

Disallow: /*/print$

Note that pattern matching in robots.txt is a Google extension (see
http://www.google.com/support/webmasters/bin/answer.py?answer=40367 for more
information).

Использованные материалы

  • README.txt модуля
  • INSTALL.txt модуля

Полезные ссылки

Авторы решений:
Категории модулей:
Версия Drupal:
 
 
 

RSS-лента новостей

Dries Buytaert по-русски
]]>Русский поиск Drupal]]>

Перенос сайта из Joomla в Drupal
Перенос сайта из WordPress в Drupal

]]> Drupal - это бесплатная система управления контентом с открытым исходным кодом ]]>