Jump to content

IFrame and other custom HTML tags


wrenbjor
 Share

Recommended Posts

I have been searching through the Forums and I found something related but I don't think this situation applies. I have an iFrame tag for an embedded Google calendar. I want to put it in a page but I don't want it in the main template. Should I make a "mini" template and call it or is there a way to put the tag in via the CMS GUI? It seems that every time I click on the "HTML" button on a text edit field and put it in, it gets filtered out. even custom <div> tags get removed. Any ideas or suggestions?

Link to comment
Share on other sites

Welcome to the forums wrenbjor!

If the calendar doesn't have to be included in the content that you will put via the GUI, you can do something like this on your template:

<?php if ($page->name == 'whatever'): ?>

"your google calendar code"

<?php endif; ?>

Where 'whatever' is the name of the page you want to put the calendar in.

Link to comment
Share on other sites

Also if you want to add it to some pages, just create checkbox field called "show_calendar" and add it to templates where you need calendar to show.

Then in your templates use this:

<?php
if ($page->show_calendar) {
 echo "<iframe here>";
}

If you need the calender in middle of your content, then you have few options. First one is to edit your body field tinyMCE options and let it allow iFrames and their attributes. Not sure how well it works in admin edit, but shouldn't be too bad. Good thing here is that it allows different iFrames easily. Bad thing is that editor can add harmful code inside content.

Other option is to use somekind of tag inside your content, ie. [[CALENDAR]] and then replace that in your template file with actual calendar code.

Link to comment
Share on other sites

Another route is to have your calendar template add it to some existing field that gets output in the main template, like $page->body:

/site/templates/calendar.php

<?php
$page->body .= "<iframe ...>";
include("./main.php"); 
Link to comment
Share on other sites

  • 1 month later...

In case it helps anyone, you can set TinyMCE to accept ALL tags by entering *[*] in valid_elements

Setup > Fields > (field with TinyMCE on it, i.e. body field) > Input > Tiny MCE Advanced

Replace everything in the valid_elements field with *[*]

This is of course if you trust the editors of your website... which I don't see being a problem most of the time. My clients don't usually want to to sabotage their own websites ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...