DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:tplmod

tplmod (template modifier) Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" unknown
  • 2023-04-04 "Jack Jackrum" unknown
  • 2022-07-31 "Igor" yes
  • 2020-07-29 "Hogfather" yes

plugin Modify template features based on ACL, IP-addresses, days of week. Features include page and site tools, logos, taglines, wiki titles, user interface language. Controls access to "do=actions". Adds optional sidebar toggle.

Last updated on
2021-12-06
Provides
Action
Repository
Source

Installation

Search and install ​the plugin using the Extension ​Manager.

Usage

This plugin enables you to modify the DokuWiki template based on IP address, ACL level of the user, and day of the week. The wiki logo (image), tagline, and the wiki name can be rotated by day or changed based on the IP address of the user. The links and buttons at top 1) and side 2) of the template can be changed based on the ACL level of the user; similarly the actions that they trigger are also governed by the ACL level of the user.

Some rationales

Being able to make these kinds of changes based on IP address makes it possible to run a site which caters to more than one entity and to give each one its own tools, logo, etc. Changing by date makes it possible to freshen the appearance of a page for repeat visitors. The ability to restrict the kinds of tools users have access to can have use for sites that want to fine-tune access. The per-user language option, which lets users select their own user-interface language, expands the usefulness of the plugin to multi-lingual sites.

Template Compatiblities

This plugin is compatible with the current dokuwiki template and with templates modeled on it. It also has built-in accommodations for the monochrome template.

Logo and Lists

When the logo image is rotated by the plugin, it is in effect replacing the default logo image. This will be found in one of three directories, as specified here: changing_the_logo. Your own replacement images will be assumed to be in the same directory as the default logo. When the template loads the default logo, it also specifies the width of the image. Therefore, if your image is a different size from the default, then you will want to specify its width. The replacement images are specified in the Configuration Options as a comma-separated list of the image names with the widths separated from the the name by a space:

  img1.png 64,img2.png 128,img3.png 256,img4.png, . . .    

The images must be listed in the order in which they will be accessed. That is, if you choose to rotate them by days of the week, then the first image must be the Sunday image, the second Monday, etc. If you do not have enough images for the seven days, then the first image (Sunday) will act as the replacement. The same principle holds true if you are rotating the logos by IP address. The images and the IP addresses must be listed in the same order as you want them accessed. If there are more IP addresses than images, then the first image in your list will be used.

There is a transparent logo.png included in the distribution. Using that as your default logo will eliminate the momentary lag between the appearance of the default image and its replacement.

Rotating Tag Lines and Wiki Names

The same principle for rotation applies to rotating tag lines and wiki names, as described above for the logos. The lists of tag lines and wiki names must be in the order in which you want them accessed by either date or IP address. Sunday will access the first tag line or wiki name, the first IP address in your list or IPs will access the first tag line or wiki name. The default replacement tag or name will be the first in its list.

Important
In order to implement tagline replacement, you have to set a Dokuwiki tagline in Dokuwiki's configuration settings. The tplmod plugin supports one level of HTML markup. For instance, you can set the Configuration tagline as <b>My thoughts about things</b> and the plugin will leave the HTML in place and replace “My thoughts about things” with a new tagline. You could in fact set the Configuration tagline as follows: <b></b>, then all of the taglines will automatically be bold.

The Date Tagline

if the tag_date_format is set, then a formatted date string will be output as the tag. The formatting uses a php date string. For instance:

  \T\o\d\a\y \i\s l F jS Y

This will output Today is Tuesday July 4th 2017 (or whatever the date is). Notice that all the text which is not part of the actual date itself is escaped: \T\o\d\a\y \i\s. Not every character has to be escaped, only those which wll be interpreted as formatting characters. The date tagline takes precedence over the rotating taglines, so you cannot have both a date tagline and rotating tagline.
Please Note: As with the rotating taglines, a Dokuwiki tagline must be set in the Configuration Manager. Moreover, for the rotatewhich option, either BOTH or TAG must be selected.

ACL controls

There are two major groups of template tools, treated as groups in the Configuration Manager, and two additional tools treated individually:

  1. The Site tools. These appear at the top of the Dokuwiki template and include Recent Changes, Media Manager, and Sitemap.
  2. The Page tools. These are displayed as icons at the right of the template and include Edit, Old Revisions, Backlinks, and Subscribe.
  3. User Profile
  4. Search Box

If a user is not eligible to use a tool, the tool will not be displayed.

You control access to these tools by selecting from the Configuration Manager which of these tools you want to control and by setting the cut-off ACL level using the acl_all configuration option. If, for instance, you set acl_all at EDIT then users with ACL of EDIT or lower will not have access to the selected tools. For tools which are not included in the Dokuwiki core and appear in the Page tools, you can add them to the Page tools input box in the form of a key word from the url of the tool. For example, in the case of the overlay, entering the word overlay in the input box would prevent the overlay window from appearing to users who do not have access.

Page Tools 'All' Setting

If the Page tools All option is selected, then all page tools will be hidden from users who fall under the acl_all setting. If, however, you would like to exclude certain core tools from this blanket prohibition, you do this using the ptools_xcl option.

Access to hidden actions

By default, when a feature that triggers an action is hidden from the user, that action disabled. If the user profile facility is hidden, a url containing do=profile will not open the user profile dialog. This behavior can be changed by setting the blocking option to false.

The sidebar toggle mechanism is enabled by setting the toggle_sidebar configuration option to true. See mturner.org for an example of its use. The toggle is an action link at the top right of the page.

An adjunct to sidebar toggling is the facility to suppress the sidebar by page and namespace. The pages and namespaces are set in the Configuration Manager, using the xcl_sidebar setting.

Supported Templates

Tplmod was initially desiged for use with the default DokuWiki template. While tplmod should work with templates based on the DokuWiki starter template, there could be differences that stand in the way of some of the functions that tplmod provides. However, there is current built-in support for these templates:

Background Color Setting

The background_color setting makes it possible to set the color of the browser area which surrounds the wiki. This can often be done using the “Template Style Settings” in the Admin panel. But there are some cases where this setting can be useful, as in the monochrome template, where the background color fills the entire browser area before the wiki page color is activated. This may cause a choppy effect as the background color for the wiki sections replace the browser color. The solution is to set the background color of the template to the page color in the “Template Style Settings”. Then the entire page is loaded using this background color, after which tplmod will set the surrounding background color. In the pattern set down by the current Dokuwiki template, the wiki page color is white (#ffffff) and the template background setting is background_alt. For this to work you have to check off default, which is the only option, and will trigger background_alt or else enter the color code for the background color which you prefer.

Individual User Interface Languages

This feature enables setting of the User Interface language on a per user basis. It's done through the User Profile feature, which can be configured to display a new sub-dialog in which the current user can set the user's own User Interface Language. This language setting carries over to subsequent DokuWiki sessions, until the user changes the language.

Note: There is no need to access this feature if the user is happy with the default language set by DokuWiki.

Configuration

The UI Language dialog will not appear in the User Profile until the administrator selects the list of languages which the wiki's users can choose from. This is done in the Configuration Manager, using the deflang option of the tplmod plugin. The selections will then show up in the UI Language dialog as a set of radio buttons.

The language change occurs immediately upon leaving the User Profile dialogs. The user can change language as need arises.

Configuration and Settings

Option Description
logos Comma separated list of image names for home page logo: names only, not paths
ips Comma separated list of IPs for rotation by IP. Rotations follow sequence of IPs
sitetools Site Tools
Remove the selected site tools. In the Dokuwiki template Site Tools are located at the top of the template.
pagetools Page Tools
Remove the selected page tools. In the Dokuwiki template these are located along the right-hand side of the template. You can remove non-standard tools, using the input box: enter them as a comma separated list of unique words from their query strings or urls. Selecting edit will also hide and disable the view source button. Current versions of tplmod support a Revert option, which is not explicitly a button, but setting this to true prevents attackers from reloading old versions of pages in place of the current versions.
profile Remove User Profile link
search Remove Search box
taglines Comma separated list of taglines
tag_date_format A PHP date format string. If present, this date string will be output as your tagline
acl_all The ACL level required for access to the sitetoools and pagetools. Users with lesser ACL levels will be barred from access to these tools. Defaults to EDIT.
dateorip Rotate logos, tag lines, and wiki names by ip address or days of the week. Select NEITHER if you do not want rotation.
rotatewhich If rotating the logo and/or tagline, select which to rotate. You have a choice of NONE, LOGO,TAG, BOTH. For the tag_date_format, either TAG or BOTH must be selected.
ptools_xcl If pagetools is set to All, you can retain selected tools by entering a comma separated list of unique words from their urls in this text box
rotate_title Rotate the wiki name (title)
wiki_names Comma separated list of wiki names
toggle_sidebar Display a toggle link in the site tools to hide and show the sidebar. Defaults to false.
blocking Prevent attempts to access hidden actions by adding do=<action> parameters to the url. Defaults to true
background_color The browser background color, i.e. surrounding the wiki page. See background_color_setting
restricted_group Name of group which is restricted from accessing the User Profile dialog. If no group is assigned and the profile option is true, all users will have the User Profile link removed.
deflang User Interface Languages. Select the languages from which users can set their own UI Language in the User Profile dialog
xcl_sidebar Comma separated list of pages and/or namespaces where sidebar should be suppressed. Pages should be in namespace:pagename format. Namespaces as namespace:*.

Development

1)
Site tools
2)
Page tools
plugin/tplmod.txt · Last modified: 2023-12-14 18:03 by Aleksandr

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