UIExtensionClass org.xwiki.plaftorm.menu.content creates a parent <ul>

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

Hello @Simpel

Nice to see advanced users extending XWiki :slight_smile:

I’m not sure why your Bookmark idea should replace the Like feature. They seem different features that are complementary rather than competing:

  • like = measure of how users like a page
  • bookmark = page useful to a user for the work he’s doing (and he/she needs to come back to that page often/quickly)

Re bookmarks, there’s also a Favorite app (in case you’re not aware of it): https://extensions.xwiki.org/xwiki/bin/view/Extension/Favorites%20Application/

Thanks

We don’t like to compete so we don’t need the “Like” as like. But the Favorite app could have done the job too. Thanks

It comes from HTML cleaning. By default, the HTML macro parses the HTML and tries to make it valid HTML. You can disable this with the clean parameter. I don’t see why you need wiki="true" here, so I would suggest replacing {{html wiki="true"}} by {{html clean="false"}}.

1 Like