0
Good afternoon, guys, okay? So I’m developing a small system with Codeigniter, and for that I’m using the template Adminlte, and now I’m creating the calendar+schedule part and for that I’m using Fullcalendar
$this->template->set('title', 'Lista de Clientes');
$data['clientes'] = $this->model->listar();
$this->template->load('layout', 'clientes_lista.phtml', $data);
Using the Template this way can already generate several views but when trying to use with Fullcalendar it defaults the template and does not display the calendar as I will show below
Template with the Fullcalendar:
The strange thing is that if you load my calendar view in the normal way it opens without problems $this->load->view('calendar_v.php'); my calendar
Code of the calendar view:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href=' <?php echo base_url(); ?>assets/calendar/fullcalendar.min.css' rel='stylesheet'>
<link href='<?php echo base_url(); ?>assets/calendar/fullcalendar.print.min.css' rel='stylesheet' media='print'>
<script src='<?php echo base_url(); ?>assets/calendar/lib/moment.min.js'></script>
<script src='<?php echo base_url(); ?>assets/calendar/lib/jquery.min.js'></script>
<script src='<?php echo base_url(); ?>assets/calendar/fullcalendar.min.js'></script>
<script>
$(document).ready(function() {
$.post('<?php echo base_url();?>calendar2/getEvents', function(data){
// Console.log para evitar transtornos
console.log(data);
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultDate: new Date(),
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: $.parseJSON(data)
});
});
});
</script>
<style>
body {
margin: 40px 10px;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
font-size: 14px;
}
#calendar {
max-width: 800px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
</body>
</html>
Due to my inexperience I can not find the reason for this behavior, I do not know if the Adminlte has any incompatibility as a script or something, also do not know if because in both views(template and calendar) have the tag can generate some problem, Thank you in advance.
Edit: giving a look at the console I found the following error:
Use
<?php echo base_url('assets/calendar/fullcalendar.min.css'); ?>
. It’s the right way.– ShutUpMagda
Thanks for the help, but continued with the same problem
– Felipe Miranda De Lima
The comment was not intended to solve the problem, it was only for you to know that this method
base_url()
has to be used the right way ;)– ShutUpMagda
there is so yes, thank you.
– Felipe Miranda De Lima
Have you tested if the links are working correctly? What is your base_url()? Is this correct? Make sure the browser is bringing the files correctly. Also make sure the data is being brought in correctly
$.post()
– Not The Real Hemingway
I found an error giving a look at the console, I edited the question.
– Felipe Miranda De Lima
Can I copy the error text? I can’t open the image.
– Not The Real Hemingway
If I understand correctly, you have two views. One is the template, and the other loads the calendar. You are trying to load the calendar inside the template, but it is empty. If so, edit the question and show how this template loads this view. You’re confused. If what I’ve noticed is correct, you’re trying to load an entire HTML page into another HTML page, and this request
$.post
doesn’t matter if you do it.– ShutUpMagda
@Shutupmagda He has, probably, a database with events and is trying to upload these events via the calendar post - Full Calendar. No Dashboard compatibility problem Adminlte, because according that page, they are integrated. It may be a problem with date format (date is always a problem).
– Not The Real Hemingway
@Nottherealhemingway, yes, yes. What is confused is the view that shows the calendar of events. Apparently, he’s not using a template (or not using it correctly), and thinks he needs to create a template
<head>
inside the view to use the Fullcalendar. In this case, it needs to show the method that calls this calendar (which should beAgenda()
) so we know if it’s true.– ShutUpMagda
I believe I have found the problem in both documents I am loading the javascript if I remove from the template it opens the calendar within the area of the template a little disfigured only but opens
– Felipe Miranda De Lima
Remove from view, not template. Template should be the same for all views. If it is the same for all, there is no need to reload scripts in them.
– ShutUpMagda
Problem that if I withdraw from view it does not recognize the script
– Felipe Miranda De Lima
So you’re doing it wrong. There’s no margin for this need to load scripts into the view. No MVC Codeigniter using template the view job is not that. The
<head>
in the view only when not using template. Or you’re not wearing template, or is using it in the wrong way. Remember: no Codeigniter, when you speak "template", is trying to say that here.– ShutUpMagda