I am new to codeigniter and so would like to know how can this code be modified to suit the MVC?Right now I have both html and php codes in the view.Any suggestions to improve it and keep it separated in controller and view is appreciated.How can I separate the php and html codes in the view?
My View is as follows
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/js/select2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".searchabledropdown").select2();
</script>
</head>
<body>
<form action="">
<div>
<select id="main_language" name ="main_language">
<option>English</option>
<option>Japanese</option>
</select>
<input type="button" value="Set Main Language">
</div>
<div>
<h3>Translation Management</h3>
</div>
<div>
<select name="lang_choice1" id="lang_choice1">
<!-- <option value="" selected="selected">-----</option>-->
<?php
$path = './application/language/';
$dir = new DirectoryIterator($path);
foreach ($dir as $fileinfo) {
if ($fileinfo->isDir() && !$fileinfo->isDot()) {
echo "<option value='" . $fileinfo->getFilename() . "'>".$fileinfo->getFilename()."</option>";
}
}
?>
</select>
=> <select name="lang_choice2">
<!--<option value="" selected="selected">-----</option>-->
<?php
$path = './application/language/';
$dir = new DirectoryIterator($path);
foreach ($dir as $fileinfo) {
if ($fileinfo->isDir() && !$fileinfo->isDot()) {
echo "<option value='" . $fileinfo->getFilename() . "'>".$fileinfo->getFilename()."</option>";
}
}
?>
</select>
</div>
My controller is as follows:
class Language extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->accesscontrol->can_or_redirect('view', 'translation');
$this->output->view('translation/language');
}
}