2017 © Pedro Peláez
 

contao-bundle contao-watchlist-bundle

Project bundle

image

heimrichhannot/contao-watchlist-bundle

Project bundle

  • Tuesday, July 24, 2018
  • by digitales@heimrich-hannot.de
  • Repository
  • 5 Watchers
  • 0 Stars
  • 44 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 29 % Grown

The README.md

Contao Watchlist Bundle

This utility bundle offers a flexible watch list for the Contao CMS., (*1)

Features

  • add files or arbitrary contao database entities like tl_news or tl_member to a watch list
  • watch lists can be viewed in the contao backend, as well
  • ajax handling for a fluent usage (data is always kept up-to-date)
  • integrating the watch list is as easy as assigning a frontend module to a layout section and adding links by using insert tags
  • download the files added to a watch list as a ZIP archive
  • contains clean templates without css styling and templates prepared with bootstrap 5 css classes
  • share watch lists via link (also to public) and copy to clipboard

Impressions

Watch list in frontend, (*2)

Watch list in frontend (here: bootstrap 5 template with modal integration), (*3)

Installation & configuration

  1. Run composer require heimrichhannot/contao-watchlist-bundle and update your database.
  2. Create a watch list config (select bootstrap 5 templates if applicable).
  3. Important: Assign the watch list config to your root page.
  4. Create a frontend module of type watchlist and add it to a layout area of your website so that it comes with each and every sub page. Select bootstrap 5 custom template if needed.
  5. Identify the template you'd like to integrate a link for adding this item to the watch list. Common situations are:
    1. ce_download.html5
    2. ce_downloads.html5
    3. news_full.html5
    4. ...
  6. Integrate the link for adding an item to the current watch list to any template by using inserttag or WatchlistLinkGenerator service.

Item types

A watch list in the context of this bundle can have multiple types of items:, (*4)

  1. File: Any file in the contao file manager
  2. Entity: Any database record (aka "entity"), e.g. tl_news, tl_member -> downloads aren't possible at the moment

Sharing watch lists

  1. Do the steps mentioned in "Installation & configuration"
  2. Create a target page for shared watch lists.
  3. In your watch list config activate the sharing feature.
  4. Create the list module for the share page. You have 2 options:, (*5)

    1. For simpler needs and file-only watch lists: Create a frontend module of the type "watchlist_share_list". This module fulfills simple needs. Image watch list items are downloadable, entity items are reachable by link.
    2. For more complex needs (like internal areas, filtering, ...): Create a list using heimrichhannot/contao-list-bundle and a reader using heimrichhannot/contao-reader-bundle., (*6)

      1. Activate the option actAsWatchlistShareTarget in the list and reader configs.
      2. Make sure, the detailsUrl in the list item template contains the watchlist GET parameter. For example, you could create a block for the detailsUrl, extend your default template and override the detailsUrl:, (*7)

        {% block detailsUrl %}
        {{ detailsUrl }}?watchlist={{ app.request.get('watchlist') }}
        {% endblock %}
        
  5. Place the module created in the previous step on the page created in the second page.

Permission handling

A watch list is private to its owner. Who is the owner depends on the context, the watch list is used in:, (*8)

Context Who is the watch list's owner?
Anonymous The current PHP session ID is used as the author
Frontend login available The current frontend user (member) is used as the author

Hint: As watch lists are currently not transferable from session to member, consider showing the watch list only after login. If you have no frontend login situation, you can ignore that, of course., (*9)

Insert tags

The following new insert tags are available. These take into account the translated jumpTo url and alias., (*10)

Name Example
{{watchlist_add_item_link::file::<file uuid (string)>::<optional: title>::<optional: watch list uuid>}} {{watchlist_add_item_link::file::2e6b6f54-e4af-11eb-b4fc-001e678385c6}}
{{watchlist_add_item_link::entity::<entity table>::<entity id>::<title>::<optional: entity url>::<optional: preview file uuid (string)>::<optional: watch list uuid>}} {{watchlist_add_item_link::entity::tl_news::1::My headline::https://example.org/my-entity::2e6b6f54-e4af-11eb-b4fc-001e678385c6}}

Developers

WatchlistLinkGenerator

Add the "Add to watchlist" button from your code:, (*11)

use Contao\Template;
use HeimrichHannot\WatchlistBundle\Generator\WatchlistLinkGenerator;

function templateListener(Template $template, WatchlistLinkGenerator $linkGenerator) {
    $template->addButton = $linkGenerator->generateAddFileLink($template->singleSrc, $template->fileTitle);
}

Symfony Events

Event Description
WatchlistItemDataEvent Modify the watchlist item before output to the watchlist module.

JavaScript events

Event Description
huh_watchlist_list_updated Is dispatched after the watchlist content is updated.

The Versions