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

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

please help.. thnx ! :D

3 answers

This widget could not be displayed.

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 ;-)

This widget could not be displayed.

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

This widget could not be displayed.

Oliver's code worked for me.  Thanks!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published 10 hours ago in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

55 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you