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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

ShortCode Help

Go to End

2 Posts   1491 Views


Community Member, 18 Posts

20 June 2010 at 2:41pm

Hi again....

I added this to my page.php

function NewsFeedSCH($arguments,$content = null,$parser = null) {
		// [NewsFeed id="Testimonials" num=2][/NewsFeed]
		if (!$arguments['id']) {
		$data = DataObject::get($arguments['id'], "", "", "", $arguments['num']); //Get Pages with ID Type
		$template = new SSViewer('NewsFeed');
		return $template->process(new ArrayData($data));	

and the file:

<% control getSomething %> 
	<div class="item">
		<div class="quote">“</div>
		<div class="blurb">$Content</div>
		<div class="title">$Title</div>
<% end_control %>

How do I register the $data variable so that I can loop through it in my template file since it is being called on the fly

The news shortcode should look something like this: [NewsFeed id="Testimonials" num=2]

I already have my shorcode parser in my _config.php file. I know that works.

Thanks Again!


Community Member, 253 Posts

21 June 2010 at 10:37am

try this:

return $template->process(new ArrayData(array('Objects' => $data)));

Then you can control 'Objects' in the template.