Lets logged-in user flag page content

FlagPages 1.0.0

Module for ProcessWire: lets logged-in users flag pages.

With this module, a logged in user can flag/unflag pages, on whose template the flag link (see below) has been placed. These flags serve as "personal bookmarks" and are not a site-wide sticky setting.

Example Screenshot

Usage


On the module's config page you can set the user roles allowed to flag pages.

On the markup side, 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");

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.

echo $flags->renderList("classname foo bar");

Optional: If you would like to apply HTML classes on the generated unordered list, supply them as a string to the function's parameter.

Outputting the flagged pages count of the logged in user

echo $flags->showFlagCount();

Returns the count of flagged pages.

Installation


  • Requirement: ProcessWire 3.x

Within module area in ProcessWire Backend

Click "New" and search for FlagPages class name.

Manually

  1. Download or git clone, rename the module folder to "FlagPages" and put it into your site/modules folder
  2. Go to modules overview page and click "Check for new modules"
  3. Install the module. The module will appear under "Flag" section.

Forum topic


https://processwire.com/talk/topic/7044-release-flagpages/

Changelog


1.0.0

  • Add PHP namespace to ensure compatibility with ProcessWire 3
  • Make classlist argument in renderList() method optional
  • Improve code comments
  • Make error output translatable

0.2.3

  • Fixing module version number to prevent octal interpretation
  • Removing double class based installation method description in readme
  • Fixing method output - returning instead of echo'ing

0.2.2

  • Add method to return flagged pages count
  • Add option to insert HTML class names as renderList's parameter

0.2.1

Using ASM select for chosing user roles with flagging permission

0.2.0

Added setting to limit flagging ability to certain user roles

0.1.1

Simplified renderList() param logic (thanks, teppo)

0.1.0

Add basic functionality

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Twitter updates

  • ProcessWire 3.0.180 core updates– More
    18 June 2021
  • Today a new version of FormBuilder has been released in the FormBuilder support board (our 50th version) and it has a lot of interesting new features, which we’ll take a closer look at in this post— More
    11 June 2021
  • ProcessWire 3.0.179 adds great new admin theme customization tools that put you in full control over the Uikit admin styles— More
    28 May 2021

Latest news

  • ProcessWire Weekly #371
    In the 371st issue of ProcessWire Weekly we'll check out ProcessWire 3.0.180, introduce a new module called Flowti Page Serializer, highlight some recent forum posts and tutorials, and more. Read on!
    Weekly.pw / 19 June 2021
  • ProcessWire FormBuilder v50 updates
    Today a new version of FormBuilder has been released in the FormBuilder support board (our 50th version) and it has a lot of interesting new features, which we'll take a closer look at in this post.
    Blog / 11 June 2021
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK