← Back to article index

Release: Flag Pages Module for ProcessWire

Finally - my first module for the CMS/CMF ProcessWire that isn't forked from some other module (like GitHub Login for ProcessWire, which is based on Facebook Login).

Example Screenshot

Download from GitHub

With this module, logged-in users are able to flag pages. I'm planning to use this in my rewrite of the Knowledge Base Site Profile. There, logged-in users were able bookmark certain wiki pages for convenience. But back in March, when I originally released this site profile, this functionality was hard-wired into the templates - but now it's a module that can easily be implemented in other contexts.

Usage

FlagPages module consists of two parts: Rendering the link and rendering a list with your current bookmarks.

First of all, load the module via:

$flags = $modules->get("FlagPages");

Rendering flag toggle link

Then, use the renderLink method and place the output in your template. By adding the link to all or just certain templates, you can control which templates can be flagged and which can't.

echo $flags->renderLink();

The default output will be "Add {Name} to flags", or "Remove {Name} from flags". You can override these labels with parameters. For example:

echo $flags->renderLink("Add %s to my bookmarks", "Remove %s from my bookmarks");

Rendering the flagged pages list

echo $flags->renderList();

This will output a simple unordered list with links to pages the currently logged-in user has set a flag to.

Background

If you have never heard of ProcessWire before, here are some links explaining its approach and advantages: