Jump to:

23370 Posts in 18160 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » The same variable a few lines down doesn't work

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

Page: 1
Go to End
Author Topic: 571 Views
  • Ryan M.
    Avatar
    Community Member
    309 Posts

    The same variable a few lines down doesn't work Link to this post

    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.

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: The same variable a few lines down doesn't work Link to this post

    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

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: The same variable a few lines down doesn't work Link to this post

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

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: The same variable a few lines down doesn't work Link to this post

    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.

    571 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.