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.

All other Modules /

Discuss all other Modules here.

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

SSViewer issue with process() and/or getTemplateContent


Reply


2 Posts   541 Views

Avatar
Epro95Z28

Community Member, 4 Posts

29 March 2012 at 6:02am

Edited: 29/03/2012 6:05am

Hello everyone, having some slight issues with my content being displayed. I've tried a few different methods on the API, to no avail.

_config.php

ShortcodeParser::get('default')->register('Accordion', array('PageExtension', 'AccordionCall'));

This is fine, at least I think it is. It's firing with no issues. Here is my routine in my page extension class. The array was a blank I fed into process() just to get it to shutup (real technical right there).

Long story short, I want it to display my Accordion.ss file. When I use getTemplateContent, it renders it as it's written. As in <% control Accordion %> and so on shows up.

   public function AccordionCall() {
      $customise = array();
      
      $template = new SSViewer('Accordion');
      $item = new ViewableData('Accordion');
      return $template -> process($item);
   }

Any help would be appreciated :)

Avatar
Epro95Z28

Community Member, 4 Posts

3 April 2012 at 6:51am

public function Accordion(){
      
   return $this-> owner -> renderWith('Accordion');
      
            
}

tada! If I want to load just a certain Holder, I use this

public function AccordionCall($arguments) {
      
      try {
         $arg = $arguments;
      } catch (Exception $e) {
         $arg = null;
      }
      
      //if there's no arguments, it will return everything
      
      if ($arg == null) {
         $controlMe = Controller::curr();
         return $controlMe-> owner -> renderWith('AccordionAll', $arguments);
      } else {
         $arg = $arguments['name'];
         $current = (DataObject::get_one('AccordionHolder',"AccordionName = '$arg'"));
         $item = ($current) ? DataObject::get('Accordion', "ParentID = $current->ID", "", "") : false;
         $item -> customise($current);         
         $controlMe = Controller::curr();   
         return $controlMe-> owner -> customise($current) -> renderWith('Accordion');

      }
         
   }

Hope this helps others...