Jump to:

3447 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Unique Template

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

Page: 1
Go to End
Author Topic: 507 Views
  • Stef87
    Avatar
    Community Member
    66 Posts

    Unique Template Link to this post

    SilverStripe 2.4.7

    I was wondering if it is possible to create a completely unique template within SS?

    What I want to do is scrape the markup from another site, echo out that markup and put a control block in one of the divs. I have the scraping working in php but I'm not sure how to proceed. Should this be a method in the controller that I call within the URL?

    I have tried a few things but the default CSS of page gets applied. My knowledge on templates isn't extensive enough to know whether this is even possible.

    Thanks in advance.

  • ccburns
    Avatar
    Community Member
    74 Posts

    Re: Unique Template Link to this post

    Hi there,

    In your method you can use the ->renderWith('templateNameHere') to allow you to render the output with a specific template. This way you can set the template up however you like.

    For example

    return $this->customise(array('AllBooks' => $AllBooks))->renderWith('MyCustomTemplateName');

    You can pass in as many DataObjectSets or ArrayData as you like for the template.

    return $this->customise(
    array(
    'absoluteURL' => Director::absoluteBaseURL(),
    'isFollowing' => $this->isUserFollowing($URLSegment),
    'profileData' => $profileData,
    'activityData' => $this->getUserActivity($URLSegment),
    'collectionData' => $collectionData,
    'MenuTitle' => $MenuTitle,
    'URLSegment' => $URLSegment,
    'checkUser' => $this->checkUser()
    )
    );

    As you can see with this second one I am passing in a lot more information for the template (but on this occasion I am using the default template). But all I would need to do is add this to the code and it would render with a custom template

    ->renderWith('MyCustomTemplateName');

  • Stef87
    Avatar
    Community Member
    66 Posts

    Re: Unique Template Link to this post

    That's great. Thanks. But will that template be free from the default CSS in SilverStripe? I think I need to set up a method in my page controller to scrape the html I need, return it as strings, use control blocks to add those strings to the template and then use a control block to pull data out of my database.

    It seems logical enough in my head but anything I put in the template is styled with BlackCandy's CSS.

  • ccburns
    Avatar
    Community Member
    74 Posts

    Re: Unique Template Link to this post

    You'll need to have a look at where the stylesheet is being included. Is it included in Page.php?

  • Stef87
    Avatar
    Community Member
    66 Posts

    Re: Unique Template Link to this post

    Yes, it is. Thanks for your help. I chose an alternate solution for this but it's good to know how to show a different template anyway.

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