Jump to:

3439 Posts in 1028 Topics by 869 members

Template Questions

SilverStripe Forums » Template Questions » Creating an Image (rather than Text)-based menu

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

Page: 1
Go to End
Author Topic: 472 Views
  • Jen
    Avatar
    Community Member
    5 Posts

    Creating an Image (rather than Text)-based menu Link to this post

    Hi. I am very new to SS, and haven't been programming for well over a decade so I am not quite up to speed with all of the code and syntax in SS. I am trying to create a menu for the home page of my site which uses images as the links instead of text. You can see the page at: http://www.mummydoit.org

    The images are meant to be positioned in the white blocks and look like polaroids.

    The code I am using is:
                   <ul class="polaroid">
                      <% control Menu(1) %>
                      <li>
                      <a href="$Link" class="pic-{$POS}">$LinkPic</a>
                      </li>                        
                      <% end_control %>
                   </ul>

    LinkPic is an image field on all top level pages in the site and I have made sure that an image is uploaded for each page. The code is working, but only for the last item in the menu. Can anyone tell me why and how to fix it?

    Eventually, I would like for the Home page to not show up on this menu, but I haven't tackled that problem yet. I am assuming it will be some sort of if statement, but if you have any ideas about that as well, I would be grateful.

    Thanks.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Creating an Image (rather than Text)-based menu Link to this post

    If you want to hide a page, untick the 'Show in Menus' checkbox in the CMS (http://2.4.userhelp.silverstripe.org/for-website-content-editors/managing-your-site/). With the missing images it looks like LinkPic isn't set at all, Make sure you can see the image thumbnail in the CMS.

  • Jen
    Avatar
    Community Member
    5 Posts

    Re: Creating an Image (rather than Text)-based menu Link to this post

    Thanks for the reply. The images are definitely loaded and thumbnails visible.

    I actually don't want to hide Home in all menus, just that menu on the home page, so I don't think the checkbox option will do what I need.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Creating an Image (rather than Text)-based menu Link to this post

    Then take a read of the first couple tutorials and introduce yourself to the page types and templates (http://doc.silverstripe.org/framework/en/2.4/reference/built-in-page-controls). You could do something like <% if URLSegment = home %><% else %> your menu code<% end_if %>. Next thing to check - what is $LinkPic? If you try $LinkPic.ID you should see a series of numbers for each image. If you only see 0's then the images aren't attached.

  • Jen
    Avatar
    Community Member
    5 Posts

    Re: Creating an Image (rather than Text)-based menu Link to this post

    Ok...feeling very sheepish and deserve an absolute slap upside the head. I was on such a roll adding pics to each page that I forgot to publish them as I went. Doh!

    Thanks for the code reference. I will give that a go and see what I can do. Thank you for all the help.

    472 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.