Codeigniter does not allow fetch of media in iframe - php

I have a files that stored in storage/employeeImages also the file name stored in database. When I want fetch files and show in modal using iFrame I'm facing 403 error.
<a href="#" data-toggle="modal" data-target="#<?= $employee['emp_id'];?>">
<img src="<?= base_url("/storage/employeeImages/".$employee['image']);?>" width="400" height="400">
</a>
<div class="modal fade" id="<?= $employee['emp_id'];?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel"><?= $employee['name'];?></h4>
</div>
<div class="modal-body">
<iframe src="<?= base_url("/storage/employeeImages/".$employee['image']);?>>" style="width:100%;height:100%"></iframe>
</div>
<div class="modal-footer">
</span>
</div>
</div>
</div>
</div>

Error 403 simply means you are trying to access a forbidden access file. You might want to check your folder properties or try moving it to an accessible directory(maybe a public folder).

Related

Show route view in modals

i want to show this
Route::resource('tags', 'TagsController');
in this modal
<div class="modal" id="modaldemo9">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content modal-content-demo">
<div class="modal-header">
<h6 class="modal-title">Supprimer tags </h6><button aria-label="Close" class="close" data-dismiss="modal"
type="button"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
</div>
</form>
</div>
</div>

in which file and where should i put a modal bootstrap?

I need to add a modal popup to the following web app:
https://github.com/gunet/openeclass/tree/3.12.x
<div class="modal fade" id="wizardmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Property</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<!-- Smart Wizard HTML -->
<div id="smartwizard">
<ul>
<li>Step 1<br /><small>Add Property</small></li>
<li>Step 2<br /><small>Type of Property</small></li>
</ul>
<div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
I'm using modal show.
$(window).on('load',function(){
$('#wizardmodal').modal('show');
});
In which file and which line should i add the above?
I have tried adding the above in index.php but nothing shows up
I can see from your code you're running bootstrap version 4. Here's a link to the documentation for how to use a modal https://getbootstrap.com/docs/4.6/components/modal.
I added a little modification to your code to get it to run. Check it below.
$(window).on('load',function(){
$('#wizardmodal').modal('show');
});
<script src="https://cdn.jsdelivr.net/npm/jquery#3.5.1/dist/jquery.slim.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/js/bootstrap.bundle.min.js"></script>
<div class="modal fade" id="wizardmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Property</h5>
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×<span>
</button>
</div>
<div class="modal-body">
<!-- Smart Wizard HTML -->
<div id="smartwizard">
<ul>
<li>Step 1<br /><small>Add Property</small></li>
<li>Step 2<br /><small>Type of Property</small></li>
</ul>
<div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

Boostrap popup from a loop in Laravel

I have content from a loop and I'm displaying title and image in a grid boxes.
In addition, in every box of content I have View more button and when a user clicks on, it shows the full content (title, image, body) in popup.
I have tested with Bootstrap modal and the popup functionality works but when I click the View more from the first box or the second, the popup always shows the content from the first box.
How can I fix this, so when a user clicks on the "View more" from the second box, to show the full content from the second box?
Every content has also ID parameter from the database, for example the first box has ID 1 and the second box has ID 2, so how can I filter that popup by the ID of the content?
Here's my code:
#foreach($drivings as $driving)
<div class="col-sm-3">
<div class="box-inner">
<div class="image">
<img class="img-fluid" src="{{ Storage::url($driving->image) }}" />
</div>
<div class="title">
{{ $driving->title }}
</div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
View more
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{{ $driving->title }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="image">
<img class="img-fluid" src="{{ Storage::url($driving->image) }}" />
</div>
<div class="modal-body">
{!! $driving->body !!}
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
You are targeting same id in each iteration #exampleModal. So, every button have same target with id #exampleModal.
So the solution is to append it with current driving id.
Assuming that you are using id for toggling modal, You can do something like this in button:
data-target="#exampleModal{{driving->id}}"
And in modal:
id="#exampleModal{{driving->id}}"
It's a pretty common problem when using foreach in blade
The problem is all your modal div have the same id so your code detects only the first one with it. You have to give different id to all your modal div and the button view more.
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal-{{ $driving->id }}">
View more
</button>
<div class="modal fade" id="exampleModal-{{ $driving->id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel-{{ $driving->id }}">{{ $driving->title }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="image">
<img class="img-fluid" src="{{ Storage::url($driving->image) }}" />
</div>
<div class="modal-body">
{!! $driving->body !!}
</div>
</div>
</div>

How to show display modal even if there is an id in URL?

I have this http://localhost/student/stud.php?id=1 in my URL since I get id of the following student. When I hover on my modal, it will not display because of this URL in the status bar: http://localhost/student/stud.php?id=1#modal. Any help? How can I solve this problem?
Check if the url has an ID using the GET method. Below is an example.
<?php if (isset($_GET['id'])) { ?>
<div class="modal fade in" id="myModal" role="dialog" style="display: block;">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
?>

codeigniter how to get infomation of a row

i am making a function is when customer click the quickview button it will be open the modal have a infomation about that product, but i don't know how to do this, i try some method but not working, so please help me.
This is my view :
<div class="row">
<h4>Feauture Product</h4>
</div>
<form method="post">
<div class="row">
<div class="product">
<?php foreach ($infolist as $info_key){ ?>
<div class="col-sm-6 col-md-3">
<div class="thumbnail">
<img src="http://wingsacessorios.com.br/public/img/vertical/img-home05.jpg" class="img-responsive">
<div class="caption">
<h5 class="text-justify">Name product: <?php echo $info_key->name; ?></h5>
<p class="text-justify">Price: <?php echo $info_key->price.' VNĐ'; ?></p>
<p class="text-center"> </i> Buy Now<i class="fa fa-eye" aria-hidden="true"></i> Quick View</p>
</div>
</div>
</div>
<?php }?>
</div>
<!-- Small modal alert when click add cart -->
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header" style="padding:5px 10px 5px 10px;">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel" style="background-color:transparent;color:#000000;">Alert from website !</h4>
</div>
<div class="modal-body">
<h5>Added product to your cart!</h5>
</div>
</div>
</div>
</div>
<!-- Modal quickview -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
if i put modal quickview code in for each loop it just display infomation of first product
To open what you have above you'll need to open the modal with
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
pay special attention to the 'data-target'. that must match the ID of your modal div:
<div class="modal fade" id="myModal"... <---
If you have multiple products on the same page your best bet will be to generate modals programmatically with Bootstrap JS Modal.js plugin
http://getbootstrap.com/javascript/#modals
edit
This is one way to do what I believe you're looking for. I may have missed a variable echo, but the basics are there.
<?php foreach ($infolist as $info_key): ?>
<div class="col-sm-6 col-md-3">
<div class="thumbnail">
<img src="http://wingsacessorios.com.br/public/img/vertical/img-home05.jpg" class="img-responsive">
<div class="caption">
<h5 class="text-justify">Name product: some product</h5>
<p class="text-justify">Price: 12 VND</p>
<p class="text-center"> </i> Buy Now <i class="fa fa-eye" aria-hidden="true"></i> Quick View</p>
</div>
</div>
</div>
<!-- Small modal alert when click add cart -->
<div class="modal fade bs-example-modal-sm" id="cartModal<?php echo $info_key->id; ?>" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header" style="padding:5px 10px 5px 10px;">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel" style="background-color:transparent;color:#000000;">Alert from website !</h4>
</div>
<div class="modal-body">
<h5>Added product <?php echo $info_key->id; ?> to your cart!</h5>
</div>
</div>
</div>
</div>
<!-- Modal quickview -->
<div class="modal fade" id="myModal<?php echo $info_key->id; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<p>Product <?php echo $info_key->id; ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<?php endforeach ?>

Categories