kuriousagency / lists
Allow users to add elements to a list: Product Favourites, Wishlists, Bookmarks, etc.
Installs: 109
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Type:craft-plugin
Requires
- craftcms/cms: ^3.0.0-RC1
This package is auto-updated.
Last update: 2024-10-26 02:05:57 UTC
README
Allow users to add elements to a list: Product Favourites, Wishlists, Bookmarks, etc.
Requirements
This plugin requires Craft CMS 3.0.0-beta.23 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require kuriousagency/lists
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Lists.
Lists Overview
This is a plugin that allows you to create lists of elements. Lists can contain a mixture of element types.
Using Lists
Lists come with 2 predefined list types: Favourites & Wishlists.
Favourites is a single list that contains products.
Example Form
<form method="post" accept-charset="utf-8"> {{ csrfInput() }} <input type="hidden" name="listType" value="favourites"> <input type="hidden" name="elementId" value="{{ product.id }}"> <input type="hidden" name="userId" value="{{ currentUser.id }}"> {% if currentUser and product.id in craft.lists.favourites.ids() %} <input type="hidden" name="action" value="lists/items/remove-item"> <button type="submit">remove</button> {% elseif currentUser %} <input type="hidden" name="action" value="lists/items/add-item"> <button type="submit">add</button> {% endif %} </form>
Variables
get an element criteria model of favourites:
craft.lists.getFavourites(userId)
if no user id is passed in then the current user will be used.
get an array of wishlists:
craft.lists.getWishlists(userId)
get lists:
craft.lists.getLists(type, userId)
type is a string of whatever you want the list type to be?
check to see if a product is in the favourites list:
craft.lists.isFavourite(productId, userId)
check to see if an element is in a list:
craft.lists.isInList(type, elementId, userId)
if no user id is passed in then the current user will be used.
Lists Roadmap
Some things to do, and ideas for potential features:
- Might have a cp interface to see the lists?
Brought to you by Kurious Agency