Jump to:

5452 Posts in 1673 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » custom sidebar crosslinks

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

Page: 1
Go to End
Author Topic: 1082 Views
  • somaboy
    Avatar
    Community Member
    8 Posts

    custom sidebar crosslinks Link to this post

    Hi

    I'm working on my first SS project and enjoy the system very much.

    In the sidebar of most pages of my website i want to enable the user to add 2-5 crosslink blocks, linking to any other pages in the site. These blocks would consist of the page's title, a truncated version of the content (say, the first line or two) and a "read more..."-link. Exactly as one would do with recent blog posts, but for more "Static" content instead.

    Instead of having the user fill out all this information, i want them to be able to choose the page they want to link to and have SS automatically pull the needed data from that page.

    How would one go about that, if it's even possible?

    I hope i'm being sufficiently clear.

    Thanks

    soma

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: custom sidebar crosslinks Link to this post

    You're going to have to dig into some code, so you might want to start by following the tutorials.

    You could make a cross link widget (http://doc.silverstripe.com/doku.php?id=widgets#writing_your_own_widgets)

    * Add a has_one relation to the SiteTree object, called LinkedPage
    * In the getCMSFields used a TreeDropdownField to let people edit LinkedPage (http://doc.silverstripe.com/doku.php?id=treedropdownfield)
    * In the template, you can use $LinkedPage.Title, $LinkedPage.Link, and $LinkedPage.Content to get to the different parts of the content.

    Then add a widget feed to your page and your template (http://doc.silverstripe.com/doku.php?id=widgets#adding_widgets_to_other_pages)

    Hope this helps!

  • somaboy
    Avatar
    Community Member
    8 Posts

    Re: custom sidebar crosslinks Link to this post

    Thanks for your prompt help.

    I'm not afraid of writing some php, but this looks a lot less straightforward than what I was expecting. Is there perhaps an existing widget with a comparable functionality that i could adapt to my needs?

    soma

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