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.

Data Model Questions /

ShortCode Help


Reply


2 Posts   1136 Views

Avatar
senica

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']) {
         return;
      }
      
      $data = DataObject::get($arguments['id'], "", "", "", $arguments['num']); //Get Pages with ID Type
      
      $template = new SSViewer('NewsFeed');
      
      return $template->process(new ArrayData($data));   
   }

and the NewsFeed.ss file:

<% control getSomething %>
   <div class="item">
      <div class="quote">“</div>
      <div class="blurb">$Content</div>
      <div class="title">$Title</div>
   </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!

Avatar
Pigeon

Community Member, 243 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.