Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

The same variable a few lines down doesn't work


Reply

4 Posts   590 Views

Avatar
Ryan M.

13 April 2010 at 7:48am (Last edited: 13 April 2010 7:49am), Community Member, 309 Posts

I have this code in a sidebar template:

<ul id="profile-menu">
      <% if isPhotoAlbum %>
      <li><a href="$Album.AddPhotosLink">Add Photos to this Album</a></li>
      <li><a href="$Album.DeleteLink">Delete this Album</a></li>
      <li class="empty">&nbsp;</li>
      <% end_if %>
      <% if isUploadPage %>
      <li><a href="$Album.DeleteLink">Delete this Album</a></li>
      <li><a href="$Album.Link">Back to Album</a></li>
      <% end_if %>
      <li><a href="$NewAlbumLink">Create a new Album</a></li>
      <% if isPhotoAlbum %>
      <li><a href="$Link">Return to Photo Gallery</a></a></li>
      <% end_if %>
   </ul><!-- profile-menu -->

The variable, $Album.DeleteLink, works just fine in the first instance it's used. In the second, in the "if isUploadPage" area, it doesn't. There is no fundamental change that occurs between the two instances that would cause it to break. The first instance prints the link just fine while the second one prints a blank.

Avatar
Double-A-Ron

14 April 2010 at 9:39am Community Member, 604 Posts

Hmph.

Weird alright. That looks all good to me. Have you checked your HTML Source just to make sure it's not being hidden?

Is this link displaying or not?

<li><a href="$Album.Link">Back to Album</a></li>

If the entire block is not displaying, isUploadPage is giving you a false when you probably aren't expecting it. If it is only the DeleteLink not displaying, it just doesn't make sense.

Aaron

Avatar
Ryan M.

14 April 2010 at 11:43am Community Member, 309 Posts

Yup, viewed source to check. The code block is printing. It's just the link that's being printed blank.

Avatar
Double-A-Ron

14 April 2010 at 12:14pm Community Member, 604 Posts

Is the other link in the block printing OK?

The only possible explaination without looking at code is all the code that is running to the point where isUploadPage() fires true, does not have access to the Album object.

You might be better off posting your class and method code.