3393 Posts in 976 Topics by 852 members
|Go to End|
21 November 2012 at 10:12pm
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.
22 November 2012 at 7:21am
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.
return $this->customise(array('AllBooks' => $AllBooks))->renderWith('MyCustomTemplateName');
You can pass in as many DataObjectSets or ArrayData as you like for the template.
'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
22 November 2012 at 10:23pm
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.
23 November 2012 at 10:54am
You'll need to have a look at where the stylesheet is being included. Is it included in Page.php?
23 November 2012 at 11:52pm
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.
|Go to Top|