Skip to content

Instantly share code, notes, and snippets.

@jreviews
Last active September 28, 2020 21:15
Show Gist options
  • Save jreviews/d25a7a2b0f90915186112cfcf9e1654f to your computer and use it in GitHub Desktop.
Save jreviews/d25a7a2b0f90915186112cfcf9e1654f to your computer and use it in GitHub Desktop.
MyLists Site Lists Custom Placement
<?php
defined('MVC_FRAMEWORK') or die;
use Clickfwd\Hook\Action;
use Clickfwd\Hook\Filter;
use JReviews\Addons\MyLists\SiteListButtons;
Action::add('site_init',function()
{
// Register connected lists
SiteListButtons::registerConnectedLists([2,3]);
// Remove lists from Add to List dropdown - OPTIONAL
SiteListButtons::removeFromDropdown([2,3]);
// Assign icon names to lists
SiteListButtons::assignIconsToLists([
1 => 'heart',
2 => 'thumbsup',
3 => 'thumbsdown'
]);
// Register icons
SiteListButtons::registerIcon('heart',[
'<svg fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"></path>
</svg>',
'<svg viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" clip-rule="evenodd"></path>
</svg>'
]);
SiteListButtons::registerIcon('thumbsup',[
'<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5"></path></svg>',
'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M2 10.5a1.5 1.5 0 113 0v6a1.5 1.5 0 01-3 0v-6zM6 10.333v5.43a2 2 0 001.106 1.79l.05.025A4 4 0 008.943 18h5.416a2 2 0 001.962-1.608l1.2-6A2 2 0 0015.56 8H12V4a2 2 0 00-2-2 1 1 0 00-1 1v.667a4 4 0 01-.8 2.4L6.8 7.933a4 4 0 00-.8 2.4z"></path></svg>'
]);
SiteListButtons::registerIcon('thumbsdown',[
'<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14H5.236a2 2 0 01-1.789-2.894l3.5-7A2 2 0 018.736 3h4.018a2 2 0 01.485.06l3.76.94m-7 10v5a2 2 0 002 2h.096c.5 0 .905-.405.905-.904 0-.715.211-1.413.608-2.008L17 13V4m-7 10h2m5-10h2a2 2 0 012 2v6a2 2 0 01-2 2h-2.5"></path></svg>',
'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M18 9.5a1.5 1.5 0 11-3 0v-6a1.5 1.5 0 013 0v6zM14 9.667v-5.43a2 2 0 00-1.105-1.79l-.05-.025A4 4 0 0011.055 2H5.64a2 2 0 00-1.962 1.608l-1.2 6A2 2 0 004.44 12H8v4a2 2 0 002 2 1 1 0 001-1v-.667a4 4 0 01.8-2.4l1.4-1.866a4 4 0 00.8-2.4z"></path></svg>
'
]);
// Register layouts
// If you register a default layout any attributes defined there will be used if not defined in the named layouts
SiteListButtons::registerDefaultLayout([
]);
SiteListButtons::registerLayout('circle-fill-red', [
'show-label' => false,
'button-class' => 'fwd-p-2 fwd-inline-flex fwd-rounded-full fwd-border-2 fwd-border-gray-300 fwd-border-solid fwd-transform hover:fwd-scale-110 fwd-duration-300 fwd-ease-in',
'button-on-class' => 'fwd-border-red-500 hover:fwd-border-red-300',
'icon-class' => 'fwd-w-6 fwd-h-6',
'icon-on-class' => 'fwd-text-red-600 hover:fwd-text-red-500',
'icon-off-class' => ' fwd-text-gray-400 hover:fwd-text-red-400',
]);
SiteListButtons::registerLayout('circle-outline-red', [
'button-class' => 'fwd-p-2 fwd-inline-flex fwd-rounded-full fwd-border-2 fwd-border-solid fwd-transform hover:fwd-scale-110 fwd-duration-300',
'button-on-class' => 'fwd-border-red-600 fwd-bg-red-500 hover:fwd-bg-red-400',
'button-off-class' => 'fwd-border-gray-300 fwd-bg-white',
'icon-class' => 'fwd-w-6 fwd-h-6',
'icon-on-class' => 'fwd-text-white',
'icon-off-class' => ' fwd-text-gray-400 hover:fwd-text-red-400',
]);
SiteListButtons::registerLayout('circle-outline-teal', [
'button-class' => 'fwd-p-2 fwd-inline-flex fwd-rounded-full fwd-border-2 fwd-border-solid fwd-transform hover:fwd-scale-110 fwd-duration-300',
'button-on-class' => 'fwd-border-teal-600 fwd-bg-teal-500 hover:fwd-bg-teal-400',
'button-off-class' => 'fwd-border-gray-300 fwd-bg-white',
'icon-class' => 'fwd-w-6 fwd-h-6',
'icon-on-class' => 'fwd-text-white',
'icon-off-class' => ' fwd-text-gray-400 hover:fwd-text-teal-400',
]);
SiteListButtons::registerLayout('fill-red', [
'icon-class' => 'fwd-w-4 fwd-h-4',
'icon-off-class' => 'fwd-text-gray-400',
'icon-on-class' => 'fwd-text-red-600',
]);
SiteListButtons::registerLayout('fill-teal', [
'icon-class' => 'fwd-w-4 fwd-h-4',
'icon-off-class' => 'fwd-text-gray-400',
'icon-on-class' => 'fwd-text-teal-600',
]);
// Register list groups
SiteListButtons::registerListGroup('outline',[
'outerClass' => 'fwd-p-2 fwd-space-x-2',
'showLabel' => false,
'layout' => [
1 => 'circle-outline-red',
2 => 'circle-outline-teal',
3 => 'circle-outline-teal'
],
]);
SiteListButtons::registerListGroup('button',[
'showLabel' => true,
'outerClass' => 'fwd-mb-3 fwd-inline-flex fwd-space-x-0',
'layout' => [
1 => 'fill-red',
2 => 'fill-teal',
3 => 'fill-teal'
],
]);
});
// The code below uses filters to automatically show the lists with the rest of the buttons in listings.
function mylists_include_site_list_buttons($buttons, $params)
{
$output = mylists_show_buttons($params['listing'], 'button');
if ($output)
{
$buttons[2][] = $output;
}
return $buttons;
}
Filter::add('listing_detail_action_buttons_extras', 'mylists_include_site_list_buttons');
Filter::add('listing_list_action_buttons_extras', 'mylists_include_site_list_buttons');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment