5450 Posts in 1672 Topics by 1197 members
|Go to End|
26 February 2009 at 8:22pm
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.
26 February 2009 at 8:34pm
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!
26 February 2009 at 10:12pm Last edited: 26 February 2009 10:14pm
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?
|Go to Top|