Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how to create a "add/remove favourite" button ??

liljoint April 23, 2012

I need to create a favourite button, how to know if a page or a user is favourite ??

please help.. thnx ! :D

3 answers

4 votes
Oli S
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 15, 2013

in velocity, you could use this:

#if($helper.page.isFavourite($action.remoteUser))
	<a href="$req.contextPath/labels/removefavourite.action?entityId=$helper.page.id&#url_xsrfToken()"  alt-title="$action.getText('favourite.add.page')" title="$action.getText('favourite.remove.page')"   class="fav-toggle active aui-button" >
		remove
	</a>
#else
	<a href="$req.contextPath/labels/addfavourite.action?entityId=$helper.page.id&#url_xsrfToken()"   alt-title="$action.getText('favourite.remove.page')" title="$action.getText('favourite.add.page')"   class="fav-toggle aui-button " >
		add
	</a>

#end

similar in java ;-)

1 vote
SanaS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2014

Thanks for the code snippet, Oliver, it helped me greatly. However, I had to make some minor adjustments:

#if($content.isFavourite($action.remoteUser))
    <a href="$req.contextPath/labels/removefavourite.action?entityId=$content.getIdAsString()&#url_xsrfToken()"  alt-title="$action.getText('favourite.add.page')" title="$action.getText('favourite.remove.page')"   class="fav-toggle aui-button">
        remove
    </a>
#else
    <a href="$req.contextPath/labels/addfavourite.action?entityId=$content.getIdAsString()&#url_xsrfToken()"   alt-title="$action.getText('favourite.remove.page')" title="$action.getText('favourite.add.page')"   class="fav-toggle aui-button">
        add
    </a>
 
#end

0 votes
eyrisone November 3, 2014

Oliver's code worked for me.  Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events