Jump to:

10848 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » SSViewer issue with process() and/or getTemplateContent

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 428 Views
  • Epro95Z28
    Avatar
    Community Member
    4 Posts

    SSViewer issue with process() and/or getTemplateContent Link to this post

    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

  • Epro95Z28
    Avatar
    Community Member
    4 Posts

    Re: SSViewer issue with process() and/or getTemplateContent Link to this post

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

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