- function get_enum_values($table, $field)
- {
- $sql = "SHOW COLUMNS FROM $table WHERE Field = '$field'";
- $type = $row['Type'];
- return $enum;
- }
- function get_enum_values($table, $field)
- {
- $sql = "SHOW COLUMNS FROM $table WHERE Field = '$field'";
- $type = $row['Type'];
- return $enum;
- }
Today We are going to change the layout of a module in Yii Framework 2.
1: Go to https://almsaeedstudio.com/ or AdminLTE-2.3.0 to download the template.
2: Extract it to module_name/web/
a: replace module_name with your module name like here my module name is backend
b: Rename the folder as you desire. Here I renamed it to template. Now my folder directory looks like backend/web/template/
3: Go to module_name/views/layouts/
a: Create files as per your choice like header.php, footer.php, menu.php, etc.php. Here we are going to create three files named header.php, side_bar.php, footer.php assuming that we have one file inside layouts folder named main.php. If not create one with the same name.
4: Go to module_name/web/template/ open index.html in one of your favourite text editor
a: copy the header part code as highlighted in screenshot, and past it to header.php
b: copy the header part code as highlighted in the screenshot, and past it to side_bar.php
c: copy the header part code as highlighted in screenshot, and past it to footer.php
5: Copy all content of index.html to main.php and remove those part which you already have copied and pasted it to respective files. For example remove header, side bar, footer content respectively. Now remove the main content part as highlighted below in screenshot.
6: Now prefix to css and js path this code to make the file path dynamic :
- <?php echo yii\helpers\BaseUrl::base(true); ?>/template/
7: Add Yii2 code whenever necessary. For example I’m going to add some of them.
a:
- <?php $this->endBody() ?>
b:
- <?php $this->beginBody() ?>
c:
- <?php $this->head() ?>
d:
- <?php $this->beginPage() ?>
e:
- <?= Breadcrumbs::widget([
- ]) ?>
f:
- <?= Alert::widget() ?>
g:
- <?= $content ?>
8: You are done. Now type URL in browser, and you’ll see new look of admin dashboard.
- <?php
- echo '<table border="1" cellpadding="0" cellspacing="0">';
- $black = true;
- for ($i = 1; $i <= 8; $i++) {
- echo "<tr>";
- for ($j = 1; $j <= 8; $j++) {
- if ($black == true)
- echo "<td style='background: #000;height: 30px;width: 30px;'> </td>";
- else
- echo "<td style='background: #fff;height: 30px;width: 30px;'> </td>";
- $black = !$black;
- }
- $black = !$black;
- echo "</tr>";
- }
- echo "</table>";
- ?>
Output:
- <?php
- function is_armstrong($digits)
- {
- $cube_digit = 0;
- foreach ($digits_arr as $digit) {
- $cube_digit += find_cube($digit);
- }
- if ($cube_digit == $digits)
- return true;
- else
- return false;
- }
-
- function find_cube($no)
- {
- return $no * $no * $no;
- }
-
-
- ?>
or
- <?php
-
- function is_armstrong($number)
- {
- $num = $number;
- $arms = 0;
- while ($number > 1) {
- $temp = $number % 10;
- $arms = $arms + ($temp * $temp * $temp);
- $number = $number / 10;
- }
- if ($num == $arms)
- return true;
- else
- return false;
- }
-
- ?>
- <?php
- for($i=1;$i<=5;$i++){
- for($j=1;$j<=5;$j++){
- if(($i==1 || $i==5) || ($j==1 || $j==5)){
- echo "<span style='color:#000;'>*</span>";
- }
- else{
- echo "<span style='color:#fff;'>*</span>";
- }
- }
- echo "<br/>";
- }
- ?>
Output:
*****
*****
*****
*****
*****