1 of 2
1
OK… almost have favorites module set up. Have some questions though. 
Posted: 03 April 2008 10:18 PM   [ Ignore ]
Sr. Member
RankRankRankRank
Total Posts:  149
Joined  2007-02-19

1. On the template that holds the {exp:favorites:save} tag, is there a way to add to this template a link to go back to the entry the visitor was one before they saved it as a favorite? Rather than clicking the back button and then refreshing?

2. What about a way to add the entry title somewhere in the template that holds {exp:favorites:save} tag so that users can be reminded of what entry they just saved as a favorite?

3. I have each members favorite items showing up on their member profile page. I have a heading that reads “Deron’s Favorite Items” and then a list of their favorite items below that. What I’d like to do is hide the heading when there are no favorites to show. Seems kinda weird to have a heading and no favorites.

I’m trying this but it’s not working… it’s removing everything from the template even when their are favorites to show:

{exp:favorites:entries weblog="courses"}
   {if count 
== 1}
   
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Favorite Courses</h2>
   <
table>
   
{/if}
    
<tr>
     <
th><a href="{path="courses/favorite-add"}{entry_id}/delete"><img src="/images/delete.gif" alt="Remove From Favorites" title="Remove From Favorites" /></a><a href="{title_permalink="courses/details"}">{title}</a></th>
     <
td>{exp:rating:stats entry_id="{entry_id}" theme="default" scale="5"}{stars_overall_avg}{/exp:rating:stats}</td>
    </
tr>
   
{if count == total_results}
   
</table>
   
{/if}
   {exp
:favorites:entries weblog="courses"}

4. Why doesn’t {if no_results} work in the {exp:favorites:entries} tag? Here’s what I’ve got that isn’t working:

<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Favorite Courses</h2>
   <
table>
    
{exp:favorites:entries weblog="courses"}
    
<tr>
     <
th><a href="{path="courses/favorite-add"}{entry_id}/delete"><img src="/images/delete.gif" alt="Remove From Favorites" title="Remove From Favorites" /></a><a href="{title_permalink="courses/details"}">{title}</a></th>
     <
td>{if no_results}<img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" /><img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" /><img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" /><img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" /><img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" />{/if}{exp:rating:stats entry_id="{entry_id}" theme="default" scale="5"}{stars_overall_avg}{/exp:rating:stats}</td>
    </
tr>
     
{/exp:favorites:entries}
   
</table>

Basically just trying to show 5 gray stars indicating no rating as of yet in the favorites:entries list.

5. As you can see from the code above, I’m using and image (delete.gif) out to the left of my favorites:entries. This allows the user to delete their favorites from their entries list. I don’t want this image to show up when another use (besides the owner) is viewing a favorites list. What kind of conditional could I use to only show this button to the owner of the favorites list?

Sorry for all the questions. Been working on this all night and can’t figure these out.

Profile
 
 
Posted: 04 April 2008 07:41 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2320
Joined  2006-10-18
deronsizemore - 03 April 2008 10:18 PM

1. On the template that holds the {exp:favorites:save} tag, is there a way to add to this template a link to go back to the entry the visitor was one before they saved it as a favorite? Rather than clicking the back button and then refreshing?

2. What about a way to add the entry title somewhere in the template that holds {exp:favorites:save} tag so that users can be reminded of what entry they just saved as a favorite?

Simple! The url already has an entry ID or URL title in it, so you can dynamically populate the weblog:entries loop smile

deronsizemore - 03 April 2008 10:18 PM

3. I have each members favorite items showing up on their member profile page. I have a heading that reads “Deron’s Favorite Items” and then a list of their favorite items below that. What I’d like to do is hide the heading when there are no favorites to show. Seems kinda weird to have a heading and no favorites.

I’m trying this but it’s not working… it’s removing everything from the template even when their are favorites to show:

{exp:favorites:entries weblog="courses"}
   {if count 
== 1}
   
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Favorite Courses</h2>
   <
table>
   
{/if}
 
<tr>
  <
th><a href="{path="courses/favorite-add"}{entry_id}/delete"><img src="/images/delete.gif" alt="Remove From Favorites" title="Remove From Favorites" /></a><a href="{title_permalink="courses/details"}">{title}</a></th>
  <
td>{exp:rating:stats entry_id="{entry_id}" theme="default" scale="5"}{stars_overall_avg}{/exp:rating:stats}</td>
 </
tr>
   
{if count == total_results}
   
</table>
   
{/if}
   {exp
:favorites:entries weblog="courses"}


4. Why doesn’t {if no_results} work in the {exp:favorites:entries} tag? Here’s what I’ve got that isn’t working:

<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Favorite Courses</h2>
   <
table>
 
{exp:favorites:entries weblog="courses"}
 
<tr>
  <
th><a href="{path="courses/favorite-add"}{entry_id}/delete"><img src="/images/delete.gif" alt="Remove From Favorites" title="Remove From Favorites" /></a><a href="{title_permalink="courses/details"}">{title}</a></th>
  <
td>{if no_results}<img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" /><img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" /><img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" /><img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" /><img src="http://www.kentuckygolfing.com/themes/rating_themes/default/images/star-0.gif" alt="0" border="0" class="rating_star" />{/if}{exp:rating:stats entry_id="{entry_id}" theme="default" scale="5"}{stars_overall_avg}{/exp:rating:stats}</td>
 </
tr>
  
{/exp:favorites:entries}
   
</table>


Basically just trying to show 5 gray stars indicating no rating as of yet in the favorites:entries list.

You’ll want to use conditionals like: {if count < 1} (less than) and {if count >= 1} (equal to or greater than)

deronsizemore - 03 April 2008 10:18 PM

5. As you can see from the code above, I’m using and image (delete.gif) out to the left of my favorites:entries. This allows the user to delete their favorites from their entries list. I don’t want this image to show up when another use (besides the owner) is viewing a favorites list. What kind of conditional could I use to only show this button to the owner of the favorites list?

Sorry for all the questions. Been working on this all night and can’t figure these out.

I’ll take a wild stab at this one and suggest the User:Is_Mine loop on it smile

 Signature 
Profile
 
 
Posted: 04 April 2008 08:31 PM   [ Ignore ]   [ # 2 ]
Sr. Member
RankRankRankRank
Total Posts:  149
Joined  2007-02-19

Thanks for the help! A couple of those were pretty obvious and I felt stupid after asking.  red face Must have been up too late last night.

I got two things left that I can’t seem to wrap my mind around how to do:

1. On the member profile page where I’m displaying that members favorite list, if they don’t have any favorites saved, I don’t want anything to show up. Here is the code I’m using:

{exp:favorites:entries weblog="courses"}
{if count 
== 1}
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Favorite Courses</h2>
<
table>
{if:else}
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Has No Favorite Courses</h2>
{/if}
 
<tr>
  <
th>{exp:user:is_mine member_id="{segment_3}"}{if mine}<a href="{path="courses/favorite-add"}{entry_id}/delete"><img src="/images/delete.gif" alt="Remove From Favorites" title="Remove From Favorites" /></a>{/if}{/exp:user:is_mine}<a href="{title_permalink="courses/details"}">{title}</a></th>
  <
td>{exp:rating:stats entry_id="{entry_id}" theme="default" scale="5"}{stars_overall_avg}{/exp:rating:stats}</td>
 </
tr>
{if count == total_results}
</table>
{/if}
 {
/exp:favorites:entries}

Everything about that code works just fine except for the {if:else}. If the member has saved a favorite (or two or three) it displays fine. If the member has no favorites I thought I’d simply show a heading that reads: {username} Has No Favorites. The problem is that this heading doesn’t show up when the user has no favorites. It’s just blank. Am I doing something wrong in the code that would cause it to not work or is it just not possible?

2. Second question is about the favorites:save template. I was able to get the “back to entry” link to display using the weblog entries and {url_title} tags like you instructed. The only last little problem now is the heading. Here’s what I’ve got in that template:

{exp:weblog:entries disable="member_data|trackbacks|pagination|categories"}
<h1>Added {title} to Favorites</h1>
{exp:favorites:save}
<p><a href="/courses/details/{url_title}" title="Go Back to {url_title}">Go back to {title}</a></p>
{/exp:weblog:entries}
</div>

The issue is that now, no matter if the user is adding the favorite or removing it or any other action, the <h1> heading on that template always reads “added to favorites” instead of for example, when removing a favorite, you would expect a heading that reads “favorite deleted” or similar. Is there any conditionals that I can use to solve this problem?

Thanks

Profile
 
 
Posted: 06 April 2008 04:33 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2320
Joined  2006-10-18
deronsizemore - 04 April 2008 08:31 PM

I got two things left that I can’t seem to wrap my mind around how to do:

1. On the member profile page where I’m displaying that members favorite list, if they don’t have any favorites saved, I don’t want anything to show up. Here is the code I’m using:

{exp:favorites:entries weblog="courses"}
{if count 
== 1}
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Favorite Courses</h2>
<
table>
{if:else}
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Has No Favorite Courses</h2>
{/if}
 
<tr>
  <
th>{exp:user:is_mine member_id="{segment_3}"}{if mine}<a href="{path="courses/favorite-add"}{entry_id}/delete"><img src="/images/delete.gif" alt="Remove From Favorites" title="Remove From Favorites" /></a>{/if}{/exp:user:is_mine}<a href="{title_permalink="courses/details"}">{title}</a></th>
  <
td>{exp:rating:stats entry_id="{entry_id}" theme="default" scale="5"}{stars_overall_avg}{/exp:rating:stats}</td>
 </
tr>
{if count == total_results}
</table>
{/if}
 {
/exp:favorites:entries}


Everything about that code works just fine except for the {if:else}. If the member has saved a favorite (or two or three) it displays fine. If the member has no favorites I thought I’d simply show a heading that reads: {username} Has No Favorites. The problem is that this heading doesn’t show up when the user has no favorites. It’s just blank. Am I doing something wrong in the code that would cause it to not work or is it just not possible?

I don’t know if it’s going to like that conditional… you’ve also specified the first header to show up when there’s ONLY1 (as opposed to 1 or more than 1)

Try this instead:

{exp:favorites:entries weblog="courses"}
{if count 
>= 1}
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Favorite Courses</h2>
<
table>
{/if}
{if count 
1}
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Has No Favorite Courses</h2>
{/if}
 
<tr>
  <
th>{exp:user:is_mine member_id="{segment_3}"}{if mine}<a href="{path="courses/favorite-add"}{entry_id}/delete"><img src="/images/delete.gif" alt="Remove From Favorites" title="Remove From Favorites" /></a>{/if}{/exp:user:is_mine}<a href="{title_permalink="courses/details"}">{title}</a></th>
  <
td>{exp:rating:stats entry_id="{entry_id}" theme="default" scale="5"}{stars_overall_avg}{/exp:rating:stats}</td>
 </
tr>
{if count == total_results}
</table>
{/if}
 {
/exp:favorites:entries}

deronsizemore - 04 April 2008 08:31 PM

2. Second question is about the favorites:save template. I was able to get the “back to entry” link to display using the weblog entries and {url_title} tags like you instructed. The only last little problem now is the heading. Here’s what I’ve got in that template:

{exp:weblog:entries disable="member_data|trackbacks|pagination|categories"}
<h1>Added {title} to Favorites</h1>
{exp:favorites:save}
<p><a href="/courses/details/{url_title}" title="Go Back to {url_title}">Go back to {title}</a></p>
{/exp:weblog:entries}
</div>


The issue is that now, no matter if the user is adding the favorite or removing it or any other action, the <h1> heading on that template always reads “added to favorites” instead of for example, when removing a favorite, you would expect a heading that reads “favorite deleted” or similar. Is there any conditionals that I can use to solve this problem?

Thanks

I have no idea how you could use any conditonals on this page…
Why not just display the entry normally, and use the {exp:favorites:save} be the one to display the message?

{exp:weblog:entries disable="member_data|trackbacks|pagination|categories"}
<h1>{exp:favorites:save}</h1>
<
h2>{title}</h2>
<
p><a href="/courses/details/{url_title}" title="Go Back to {url_title}">Go back to {title}</a></p>
{/exp:weblog:entries}
</div>

 Signature 
Profile
 
 
Posted: 06 April 2008 08:30 PM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  25
Joined  2007-09-24

For number 5 I used this:

{if logged_in_member_id == '{segment_3}'} [Show Delete Button]

That only works if segment_3 in the URL is the users ID

Profile
 
 
Posted: 06 April 2008 08:43 PM   [ Ignore ]   [ # 5 ]
Sr. Member
RankRankRankRank
Total Posts:  149
Joined  2007-02-19
Pie Man - 06 April 2008 04:33 PM

I don’t know if it’s going to like that conditional… you’ve also specified the first header to show up when there’s ONLY1 (as opposed to 1 or more than 1)

Try this instead:

{exp:favorites:entries weblog="courses"}
{if count 
>= 1}
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Favorite Courses</h2>
<
table>
{/if}
{if count 
1}
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Has No Favorite Courses</h2>
{/if}
 
<tr>
  <
th>{exp:user:is_mine member_id="{segment_3}"}{if mine}<a href="{path="courses/favorite-add"}{entry_id}/delete"><img src="/images/delete.gif" alt="Remove From Favorites" title="Remove From Favorites" /></a>{/if}{/exp:user:is_mine}<a href="{title_permalink="courses/details"}">{title}</a></th>
  <
td>{exp:rating:stats entry_id="{entry_id}" theme="default" scale="5"}{stars_overall_avg}{/exp:rating:stats}</td>
 </
tr>
{if count == total_results}
</table>
{/if}
 {
/exp:favorites:entries}

Hmmm, nope. With the way you’ve got it there, the {if count >= 1}, it ends up displaying the <h2> for however many favorites have been saved. So when I tested and had three favorites saved, it ended up displaying the <h2> three times. With {if count == 1} it only displays it once no matter how many favorites have been saved. The {if count < 1} conditional doesn’t work at all for when there are no favorites. No big deal, I will just not display anything when no favorites have been saved.

Pie Man - 06 April 2008 04:33 PM

I have no idea how you could use any conditonals on this page…
Why not just display the entry normally, and use the {exp:favorites:save} be the one to display the message?

{exp:weblog:entries disable="member_data|trackbacks|pagination|categories"}
<h1>{exp:favorites:save}</h1>
<
h2>{title}</h2>
<
p><a href="/courses/details/{url_title}" title="Go Back to {url_title}">Go back to {title}</a></p>
{/exp:weblog:entries}
</div>

ehhh, yeah, you’re right. That’s much easier. I have a tendency to make things more difficult than they have to be sometimes. wink

Thanks for the assistance!

Profile
 
 
Posted: 06 April 2008 08:56 PM   [ Ignore ]   [ # 6 ]
Sr. Member
RankRankRankRank
Total Posts:  149
Joined  2007-02-19

Forgot about following up on this question in the first message of this thread. On the member profile page where I’m displaying the member’s favorites, I’m also displaying that favorite’s overall rating. If they save an entry as a favorite but the entry does not have a rating yet, it should simply show up in the favorites list with five gray stars next to it.

As it is now, I’m getting no stars. What’s weird to me is that I’m using the exact same code (I think?) for this feature as I am to display five gray stars (no rating) on the actual entry page itself and it works just fine.

Here’s my code:

{exp:favorites:entries weblog="courses"}
   {if count 
== 1}
   
<h2 class="favoriteCoursesHeading">{if screen_name != ""}{screen_name}'s{if:else}{username}'s{/if} Favorite Courses</h2>
   <
table>
   
{/if}
    
<tr>
     <
th>{exp:user:is_mine member_id="{segment_3}"}{if mine}<a href="{path="courses/favorite-add"}{entry_id}/delete"><img src="/images/delete.gif" alt="Remove From Favorites" title