Hi.
Today I reworked the “Like” extension. I never liked the position - a lot of users never ever realised them. So I made it to “Bookmarks”. I moved the whole code into an UIExtensionClass org.xwiki.plaftorm.menu.content and tweaked it a lot. The code inside this class is:
{{velocity}}
{{html wiki="true"}}
#if ($services.like.displayButton($doc))
## We want to be sure that the async rendering framework invalidate cache if the document is modified.
#set ($discard = $services.async.useEntity($doc))
#set ($optLikeCount = $services.like.getLikes($doc))
#if ($optLikeCount.isPresent())
#set ($discard = $xwiki.ssx.use('XWiki.Like.LikeUIX', {'theme': $themeDocFullName}))
#set ($discard = $xwiki.jsx.use('XWiki.Like.LikeUIX'))
<li class="btn-group">
<input id="is-liked" type="hidden" value="$services.like.isLiked($doc)" />
#if ($services.like.isLiked($doc))
#set ($heartIconName = 'bookmark')
#set ($titleMessageTranslationKey = "like.toggle.hint.unlike")
#else
#set ($heartIconName = 'bookmark-o')
#set ($titleMessageTranslationKey = "like.toggle.hint.like")
#end
#set ($disabledButton = false)
#if (!$services.like.isAuthorized($doc))
#set ($disabledButton = true)
#set ($titleMessageTranslationKey = "like.toggle.hint.like.noright")
#end
<button type="button" class="like-button-upper btn btn-default"
#if($disabledButton) disabled #{end}
title="$escapetool.xml($services.localization.render($titleMessageTranslationKey))"
aria-label="$escapetool.xml($services.localization.render($titleMessageTranslationKey))">
<span id="like-button-icon" class="fa fa-$heartIconName"></span>
</button>
</li>
#end
#end
{{/html}}
{{/velocity}}
As you can see I started html with an <li> but in the dom there is always a parent <ul>. Where does it come from? Is there a possibility to omit it? The <ul id="contentmenu"> should be 5 <li> in a row.
For a quick access to the user’s own bookmarks we created a noticeable link in the topmenu to a page listing them in a table.
We think it’s more useful to have bookmarks then to see how many users like an article. An article isn’t worth any less just because it has few likes.
Regards, Simpel
