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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Embedding Google Calendar to site


Reply


5 Posts   2585 Views

Avatar
Valorinbattle

Community Member, 95 Posts

5 March 2009 at 1:32pm

I'm trying to embed a Google Calendar to my site but the HTML Editor keeps stripping out the <iframe>. I saw some old posts in the archives about this, but don't have a clue what I'm doing with the TinyMCE. Also, Double-A-Ron has an archive about creating a new page type (CalendarPage) and inserting this code in the "class CalendarPage_Controller extends Page_Controller" section of CalendarPage.php:

public function getGCalHTML()
{
$html = '<iframe src="http://www.google.com/calendar/embed?showCalendars=0&amp;height=600&amp;wkst=1&amp;bgcolor=%233366ff&amp;src=orphanhope%40gmail.com&amp;color=%232952A3&amp;ctz=Africa%2FJohannesburg" style=" border:solid 1px #777 " width="800" height="600" frameborder="0" scrolling="no"></iframe>'

return $html;
}

But when I do this, I get a parse error for that last line that says "return $html;"

Any help would be appreciated. Thanks!
~ James

Avatar
Bambii7

Community Member, 254 Posts

5 March 2009 at 3:13pm

I've had the some issue, with iframes and onClicks. Silverstripe is being to cleaver and brutally pulling these out. Kind of forces the admin to think of a more compliant way to implement these things.

you're missing a closing semi-colon at the the end of the $html variable, It worked a treat after that.

Hope that helps

Avatar
Valorinbattle

Community Member, 95 Posts

5 March 2009 at 3:37pm

Bambii7 thanks for the help!

So should it read like this:

return $html;;
}

Avatar
Bambii7

Community Member, 254 Posts

5 March 2009 at 4:06pm

Um more like

public function getGCalHTML()
{
$html = '<iframe src="http://www.google.com/calendar/embed?showCalendars=0&amp;height=600&amp;wkst=1&amp;bgcolor=%233366ff&amp;src=orphanhope%40gmail.com&amp;color=%232952A3&amp;ctz=Africa%2FJohannesburg" style=" border:solid 1px #777 " width="800" height="600" frameborder="0" scrolling="no"></iframe>';

return $html;
}

php needs know when you're done defining a statement or variable. It's pretty mush a full stop after a sentace.

$html = 'stuff to print';
The semi-colon at the end of that variable tells php it's the end of that statement.

Avatar
Valorinbattle

Community Member, 95 Posts

5 March 2009 at 7:51pm

Bambii7 - thank you! That worked perfectly.

~ James