CI goes crazy with iframes - CelticPhantom - 02-25-2024
Hi,
I was trying to embed youtube videos into my website.
When CI encounters an iframe tag on the page it throws a whole load of errors basically going through my model class and finding an error with every method.
My model class is working fine.
This is very unusual, I have no idea where the errors are coming from. Even when the iframe is not in a PHP block the output at any iframe is a bunch of erroneous error messages.
Does anyone know what is going on here?
I believe I am using CI version 3.
Here is the code for my partial view:
Code: <section>
<!-- <iframe width="300" height="300" src="https://www.youtube.com/embed/mIStB5X4U8M" title="Prime numbers | Factors and multiples | Pre-Algebra | Khan Academy" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> -->
<iframe src="https://programiz.pro" title="programiz pro website" height="500" width="500" ></iframe>
<?php
// $youtubeurl = "https://www.youtube.com/embed/mIStB5X4U8M";
// $youtubeurl = "https://www.youtube.com/watch?v=mIStB5X4U8M";
// echo '<iframe width="560" height="315" src="'.$youtubeurl.'" frameborder="0" allowfullscreen></iframe>';
?>
</section>
This is the error that is shown when this view is displayed
Code: A PHP Error was encountered
Severity: Notice
Message: Trying to get property 'section' of non-object
Filename: models/CourseModel.php
Line Number: 47
Backtrace:
File: /home/wayconte/public_html/Course/application/models/CourseModel.php
Line: 47
Function: _error_handler
File: /home/wayconte/public_html/Course/application/controllers/Course.php
Line: 79
Function: getPrevTopic
File: /home/wayconte/public_html/Course/index.php
Line: 322
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Trying to get property 'topicOrder' of non-object
Filename: models/CourseModel.php
Line Number: 52
Backtrace:
File: /home/wayconte/public_html/Course/application/models/CourseModel.php
Line: 52
Function: _error_handler
File: /home/wayconte/public_html/Course/application/controllers/Course.php
Line: 79
Function: getPrevTopic
File: /home/wayconte/public_html/Course/index.php
Line: 322
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/wayconte/public_html/Course/system/core/Exceptions.php:272)
Filename: core/Common.php
Line Number: 573
Backtrace:
File: /home/wayconte/public_html/Course/application/models/CourseModel.php
Line: 61
Function: get
File: /home/wayconte/public_html/Course/application/controllers/Course.php
Line: 79
Function: getPrevTopic
File: /home/wayconte/public_html/Course/index.php
Line: 322
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Exceptions::$load
Filename: html/error_db.php
Line Number: 81
Backtrace:
File: /home/wayconte/public_html/Course/application/views/errors/html/error_db.php
Line: 81
Function: _error_handler
File: /home/wayconte/public_html/Course/application/models/CourseModel.php
Line: 61
Function: get
File: /home/wayconte/public_html/Course/application/controllers/Course.php
Line: 79
Function: getPrevTopic
File: /home/wayconte/public_html/Course/index.php
Line: 322
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/wayconte/public_html/Course/system/core/Exceptions.php:272)
Filename: core/Common.php
Line Number: 573
Backtrace:
Exception : A serious error has occurred
Please report the following information to IT
An uncaught Exception was encountered
Type: Error
Message: Call to a member function view() on null
Filename: /home/wayconte/public_html/Course/application/views/errors/html/error_db.php
Line Number: 81
Backtrace:
File: /home/wayconte/public_html/Course/application/models/CourseModel.php
Line: 61
Function: get
File: /home/wayconte/public_html/Course/application/controllers/Course.php
Line: 79
Function: getPrevTopic
File: /home/wayconte/public_html/Course/index.php
Line: 322
Function: require_once
Can anyone tell me why CI is spewing this out when it encounters an iframe?
Many thanks,
Fintan
RE: CI goes crazy with iframes - luckmoshy - 02-25-2024
Severity: Notice
Message: Trying to get the property 'section' of non-object
Filename: models/CourseModel.php
Line Number: 47
Don't you see here that there is an issue
RE: CI goes crazy with iframes - CelticPhantom - 02-26-2024
(02-25-2024, 10:26 PM)luckmoshy Wrote: Severity: Notice
Message: Trying to get the property 'section' of non-object
Filename: models/CourseModel.php
Line Number: 47
Don't you see here that there is an issue
Hi thanks for the reply.
My issue is that if I have this code:
Code: <section>
CodeIgniter
<h2>It really is</h2>
</section>
it works as expected.
As soon as I change this to:
Code: <section>
CodeIgniter
<iframe src="https://programiz.pro" title="programiz pro website" height="500" width="500" ></iframe>
</section>
CodeIgniter throws up the error messages.
Why would it even check/run my data model when all I am doing is inserting HTML code?
The data model code is working fine elsewhere in my project so there is no issue with that.
Thanks
RE: CI goes crazy with iframes - InsiteFX - 02-26-2024
Why not try using CodeIgniter 4 html_helper -> video which embeds videos.
HTML Helper - video
RE: CI goes crazy with iframes - JustJohnQ - 02-27-2024
Without calling any model, the following code works fine in my local 4.4.6:
Code: <section>
<iframe width="300" height="300" src="https://www.youtube.com/embed/mIStB5X4U8M" title="Prime numbers | Factors and multiples | Pre-Algebra | Khan Academy" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
<iframe src="https://programiz.pro" title="programiz pro website" height="500" width="500" ></iframe>
<?php
$youtubeurl = "https://www.youtube.com/embed/mIStB5X4U8M";
$youtubeurl = "https://www.youtube.com/watch?v=mIStB5X4U8M";
echo '<iframe width="560" height="315" src="'.$youtubeurl.'" frameborder="0" allowfullscreen></iframe>';
?>
</section>
RE: CI goes crazy with iframes - CelticPhantom - 02-27-2024
I am using CI 3.1.0 so cannot use CI 4 libraries (I assume).
Is there a configuration setting anywhere in CI 3.1 that prevents certain HTML elements from being used?
This is the only thing that I can think of.
Many thanks
RE: CI goes crazy with iframes - JustJohnQ - 02-27-2024
I tried my code on a local Codeigniter 3.1 site, still no problems. It displays just fine.
I even tried calling the iframe as a sub-page with the following code:
Code: <!-- Main content -->
<section class="content">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Test</h3>
</div><!-- /.box-header -->
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="text-nowrap dtHorizontalExampleWrapper">
<p>Main text goes here</p>
</div>
<div>
<?php $this->load->view('development/admin/iFrame'); ?>
</div>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.box-body -->
</div><!-- /.box -->
</section>
RE: CI goes crazy with iframes - CelticPhantom - 02-27-2024
(02-27-2024, 08:01 AM)JustJohnQ Wrote: I tried my code on a local Codeigniter 3.1 site, still no problems. It displays just fine.
I even tried calling the iframe as a sub-page with the following code:
Code: <!-- Main content -->
<section class="content">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Test</h3>
</div><!-- /.box-header -->
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="text-nowrap dtHorizontalExampleWrapper">
<p>Main text goes here</p>
</div>
<div>
<?php $this->load->view('development/admin/iFrame'); ?>
</div>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.box-body -->
</div><!-- /.box -->
</section>
Yes it should just work. That is why I am wondering if there is some configuration setting that prevents the html tag iframe from working on my server.
Thanks for your feedback.
RE: CI goes crazy with iframes - JustJohnQ - 02-27-2024
Go back to the basics. Remove all references to a model and see if you can get the iframe to work with something like the code I provided. It pretty much looks like a typo somewhere but without full code it's hard to tell. Also check your page source with F12 (in most, if not all, browsers) to see if there are any irregularities.
RE: CI goes crazy with iframes - CelticPhantom - 02-29-2024
Fixed it.
Just run the code on a browser that is not Firefox.
Is there any CI/PHP code that I can use to check what browser is being used?
|