17488 Posts in 4473 Topics by 1978 members
|Go to End|
17 November 2008 at 9:41am
I am new to SilverStripe and I liked its functionality to make a really nice website in a short time. I am just stuck with google calendar at the moment. I am unable to embed it into a page. I tried pasting the embedding code in HTML View, but it just won't work. Can anyone please help me.
17 November 2008 at 10:14am Last edited: 17 November 2008 10:19am
TinyMCE by default strips alot of HTML from the CMS side of things. However you can change the setup of TinyMCE so that it accepts most raw html. This not an ideal solution however, as it means that any user who has access to the admin, can put any HTML markup they like on your pages, potentially throwing out your design, or possibly launching an XSS attack.
This solution involves extending the Page and adding a method that hardcodes, and returns the HTML to the SS template. To understand more about how this works, I suggest you go through the Tutorials one by one. They will give you all the basics you need to know about extending Silverstripe this way.
17 November 2008 at 10:17am
Thanks a lot Aaron,
Really appreciate your help. I will go this way and let you know, how things went.
17 November 2008 at 10:30am Last edited: 17 November 2008 10:33am
Here's a simple method that you can use:
Say you are just using a Page type. The code that does the work will be in /mysite/Page.php.
If you add a method to the PageController in that file that returns the HTML you require, you will be able to access that code in all of your Pages that are of this type.
Here is a simple method to get you started.
public function getGCalHTML()
$html = '<iframe src="http://www.google.com/calendar/embed?src=kse%40neteffects.no&title=Kalender%20for%20Kim%20Stian&height=614" style=" border-width:0 " width="640" frameborder="0" height="614"></iframe>'
Then, in your Page.ss file, you simply call this method to output the html that is returned:
Note, Div's are not required. The $getGCalHTML will output whatever it is that make that method return.
The above example is a good way for you to understand how it all works, but probably not ideal for production, as it will show your calendar on every page that is set as a normal page in your admin. You probably only want this on one page, in which case you need to create a new page type just for this (e.g. CalendarPage). The tutorial on making a custom home page is exactly what you need to look at here.
Hope that helps.
17 November 2008 at 10:36am
Thanks a ton, Your first reply, did the trick. Its all working now.
17 November 2008 at 10:51am
Glad it helped.
Just keep in mind that accepting too much html into your CMS opens doors to other potential problems. If you are the only one maintaining the site, it should be fine. But if this site is for a client or multiple content administrators, it's giving them a bit too much control over they layout.
If it were me, at the very worst, I would only mod TinyMCE to allow iframes for this problem.
But the option of extending the page, and hardcoding the HTML there is far and away the most secure option and gives you total control.
|Go to Top|