Signmaker UI¶
Signmaker UI connects Drupal to the sfenvironment/signmaker PHP library, which builds printable signs for refuse bins. The module provides a block that embeds the sign maker in an iframe. Visitors pick item images for one refuse type (compost, recycle or landfill), see them placed on a background image, and download the sign as a letter-size landscape PDF. Site editors manage the item images as media items.
For a full description of the module, visit the project page.
Submit bug reports and feature suggestions, or track changes in the issue queue.
Table of contents¶
- Requirements
- Installation
- Configuration
- Usage
- Troubleshooting
- Maintainers
Requirements¶
- Drupal 10.3 or later, or Drupal 11, on PHP 8.1 or later.
- The sfenvironment/signmaker
library, which uses Dompdf to render the
PDF. It has no tagged releases, only
dev-master. - File (Field) Paths, which saves each item image into the directory for its refuse type.
- The configuration the module installs (the Signmaker Images media type and its fields and displays) also depends on these modules, which must be enabled before this module:
- Core: Media, Media Library, Image, File, Options, Path and Content Translation.
- SVG Image.
- Field Permissions.
The module expects this file layout:
- The Composer
vendordirectory sits next to the Drupal web root, as in thedrupal/recommended-projecttemplate. The library's stylesheet and script are served from../vendor/sfenvironment/signmaker/assets/, relative to the web root. - The public files directory is reachable as
files/in the web root, both on disk and by URL. The block gives the library the directoryfiles/signmaker/<refuse type>, and the library uses that relative path to read the directory and to build the image URLs.
Installation¶
Install as you would normally install a contributed Drupal module. For further information, see Installing Drupal Modules.
Because the library is only available as dev-master, require it explicitly
unless the site's minimum-stability is dev:
composer require drupal/signmaker_ui sfenvironment/signmaker:dev-master \
drupal/svg_image drupal/field_permissions
drush en media media_library image file options path content_translation \
svg_image field_permissions
drush en signmaker_ui
Installing the module creates the directories public://signmaker/compost,
public://signmaker/recycle and public://signmaker/landfill, and the
Signmaker Images media type with an Image field and a Refuse Type field.
Configuration¶
- Grant the Use signmaker permission (
use signmaker) to every role that should use the sign maker, including Anonymous user for a public page. It controls access to/signmaker_api, which the block's iframe loads, and to the library's assets. - Add the background image for each refuse type: a file named
background.<extension>, such asbackground.png, inpublic://signmaker/<refuse type>/. You can upload it as a Signmaker Images media item with that file name and the matching Refuse Type, or copy it into the directory. - Add the item images as Signmaker Images media items (Content » Media » Add
media » Signmaker Images). Each needs an image (png, gif, jpg, jpeg or webp)
and a Refuse Type. File (Field) Paths saves the image as
public://signmaker/<refuse type>/<original file name>. Every file in that directory other than the background is offered as an item. - Place the Signmaker Block in Structure » Block layout, or wherever blocks can be placed, and set:
- Type: the refuse type whose directory the sign maker uses.
- Bounding Box of Images: where selected items appear on the background image, as percentages. Top and Left are offsets from the top and left edges. Right and Bottom are measured from the left and top edges as well, so 10, 90, 90, 10 leaves a margin of 10% on every side.
Place one block per refuse type.
Usage¶
The block shows the background image and a menu of the item images in an
iframe. Clicking an item adds it to the sign or removes it; a sign holds up to
eight items, four to a row. Start Over clears the selection. Save PDF
sends the sign to /signmaker_api, which renders it with Dompdf and returns a
PDF that the browser downloads as signmaker.pdf.
The iframe is resized to the height of its content when it loads. It is measured
again 500 milliseconds after a click on a .nav-tabs .nav-link element, so the
block can sit inside Bootstrap tabs.
Deleting a Signmaker Images media item deletes its image file, which removes the item from the sign maker.
Troubleshooting¶
- The iframe shows "Access denied". The role lacks the Use signmaker permission.
- The iframe shows "An error occurred while processing your request." The
library could not build the sign maker. The reason is logged in the
signmaker_uichannel (Reports » Recent log messages). "is not a directory" meansfiles/signmaker/<refuse type>does not exist relative to the web root; "Background file not specified" means the directory has nobackground.*file. - The sign maker is unstyled or its item menu is empty. The stylesheet
and script are not found at
../vendor/sfenvironment/signmaker/assets/relative to the web root. Check where thevendordirectory is. - Items are missing from the PDF. Dompdf may read local files only from the
library's CSS directory and from
/files. The public files directory must resolve to a path under/files. - The module will not install because of unmet dependencies. Enable the modules listed under Requirements first.
Maintainers¶
- Tyler Brown Cifu Shuster - tbcs
This project has been sponsored by: