0

Just upgraded my solspace favorite to version 4.0.

In favorite version 3 I could use

  {if saved}{/if} and {if not_saved}{/if} 

My question: I want to use a variable to set my css to "active" So if I already added that member to my favorites the link will be red. If not than the link will be blue.

What I tried so far and does not work:

  {exp:favorites:info username="{visitor:email}" disable_pagination="yes"}
  {if favorites:favorite_id == "{favorites:favorite_id}"}

or

  {exp:favorites:members favorites_username="{visitor:email}" disable_pagination="yes"}
  {if favorites_username == "{visitor:email}"}
  <li class="item-1 active"><a href="#">fav</a></li>
  {if:else}
  <li class="item-1"><a href="#">fav</a></li>
  {/if} 
  {/exp:favorites:members}

Hope someone could point me in the right direction...

Solspace Favorite 4.0.2 Expressionengine 2.9.2

1 Answer 1

0

To check if a member has been favorited, you would use {exp:favorites:info} and check if there are any results (which means the member has been favorited) or not (which means the member has not been favorited). Eg:

{exp:favorites:info member_id="3"}
    RED (favorited)
    {if favorites:no_results}
        BLUE (not favorited)
    {/if}
{/exp:favorites:info}

As with any "if no_results"-type conditionals, when that conditional is true, everything outside of the conditional will not parse nor be displayed (which is why "RED" isn't wrapped with anything above).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.