How do I remove the slash that appeared right after the body tag? - codeigniter

My website was working fine, when all of a sudden a slash appeared right after the body tag. I tried to find out what was wrong but I had no luck.
How to fix this?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Toucan | <?=$title?></title>
<?php $this->load->view('include/head'); ?>
</head>
<body>
<div id="container">
<?php $this->load->view('include/header'); ?>
<?= $slideshow ?>
<table id="main">
<tr>
<?php if ($sidebar):?>
<td width="150px"><div id="sidebar"><?= $sidebar ?></div></td>
<?php endif; ?>
<td><div id="content"><?= $content ?></div></td>
</tr>
</table>
<?php $this->load->view('include/footer'); ?>
</div>
</body>
</html>

You should take a look at the end of your controller to check if you have a PHP closing tag : ?>. And maybe something like / after it...
This is good practice to omit the PHP closing tag at the end of your scripts.

I just google your webpage (toucan-eng.com) and a slash is showing in the main webpage. The title tag should be inside the head tag and then you need to put the body tag. Hope this can help you

Related

How to extend multiple templates in Blade (Laravel 5)?

I have the following files:
foo.blade.php
<html>
<head>
</head>
<body>
<h1>Foo Template</h1>
#yield('content')
</body>
</html>
bar.blade.php
<h2>Bar Template</h2>
<div class="bar-content">
#yield('bar-content')
</div>
I want to create another file that is able to extend both the above templates. e.g something like this:
#extends('foo')
#section('content')
<p>Hello World</p>
#extends('bar')
#section('bar-content')
<p>This is in div.bar-content</p>
#endsection
#endsection
To give:
<html>
<head>
</head>
<body>
<h1>Foo Template</h1>
<p>Hello World</p>
<h2>Bar Template</h2>
<div class="bar-content">
<p>This is in div.bar-content</p>
</div>
</body>
</html>
How can I do this?
Use multiple files.
for eg;
layout.blade.php:
#include('header')
#yield('layout_content')
#include('footer')
second.blade.php
#extends('layout')
#section('layout_content')
<div>
#yield('second_content')
</div>
#stop
third.blade.php
#extends('second.blade.php')
#section('second_content')
<h1>Hello World!</h1>
#stop
You can include #yield in any of the parent files and can be used in the child
I would recommend using components. Here is an example.
It seems to me layout/include has a weird logic when there are many of them and you start nesting them. Components are pretty straight forward. For these nested structures you are building there, components also have slots.
I think it's not possible to do what you want here, at least without extending Blade:
https://laravel.com/docs/5.1/blade#extending-blade
If I were you, I'd rearchitectured my views hierarchy to keep things simple.
I do not know if this will work, but try #include instead of #extends for your bar template. The put your section for bar below the other section (not nested). I did not tested this, so I hope it works ;)
// EDIT:
Try it with an if-statement in your foo file:
<html>
<head>
</head>
<body>
<h1>Foo Template</h1>
#yield('content')
#if(isset($displayBar) && $displayBar == true)
#include('dashboard.test.bar')
#endif
</body>
</html>
And now the child view:
#extends('dashboard.test.foo')
#section('content')
<p>Hello World</p>
#endsection
<?php $displayBar = true ?>
#section('bar-content')
<p>This is in div.bar-content</p>
#endsection
#php
$ext = '';
#endphp
#if (Request::segment(1)=='explications')
#php
$ext = '_explications'
#endphp
#endif
#extends('pages_templates/template_page_fluid'.$ext)

Why the header and footer comes after body when rendered? (Processwire)

Why the header and footer comes after body when rendered? (Planets Tutorial). The planets who are using the planet.php template are children of a page Planets which is based on basic-page.php template. The About page children pages works fine though.
site/templates/planet.php
<html>
<head>
<title><?php echo $page->title; ?></title>
</head>
<body>
<h1><?php echo $page->title; ?></h1>
<h2>
Type: <?php echo $page->planet_type; ?>,
Age: <?php echo $page->planet_age; ?> years
</h2>
<p><?php echo $page->planet_summary; ?></p>
</body>
</html>
Doing a manual intermediate install solved it.

Only first page is saved to pdf from html using dompdf with codeigniter

I am trying to create a pdf from html using dompdf with codeigniter. I have two html pages. My problem is that only the first page is saved in the pdf file. The second one is gone.
Here is my code :
$this->load->library('pdf');
$html = $this->load->view('reports_html/couver1','',true);
$html .= $this->load->view('reports_html/reportContentImageLeft','',true);
$this->pdf->load_html($html);
$this->pdf->render();
other code
$this->data['view'] = $this->load->view('reports_html/reportContentImageLeft','',true);
$html = $this->load->view('reports_html/couver1',$this->data,true);
// $this->pdf->load_html($html);
$this->pdf->load_view('reports_html/couver1',$this->data,true);
$this->pdf->render();
i did like you said but only prints on the pdf file the first page
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>on.plans - reports - cover page 1</title>
<link href="<?php echo base_url()."css/reports.css"?>" rel="stylesheet" type="text/css">
</head>
<body>
<div id="page">
<div id="section" class="cover">
<div class="logo">
<img src="/path/to/officeLogo.jpg" width="300px" height="150px">
</div>
<h1>Meeting date</h1>
<h3>Project name</h3>
</div>
</div>
</body>
</html>
<?php echo $view; ?>
i added the view but its not working
thanks for your answer
You can try something like this:
$data['view'] = $this->load->view('reports_html/reportContentImageLeft','',true);
$html = $this->load->view('reports_html/couver1',$data,true);
$this->pdf->load_html($html);
$this->pdf->render();
$dompdf->stream("test.pdf");
And in your reports_html/couver1 view need do something like this <?=$view;?>
This solution is not the best - but it is work.

codeIgniter form validation doesn't work when passing view as string

I am currently learning CodeIgniter and using it for a small project. I would like to make a template so that I don't need to write repeated code for the views. I like jruzafa's answer in this post: How to Deal With Codeigniter Templates?
In controller:
//Charge the view inside array
$data['body'] = $this->load->view('pages/contact', '', true);
//charge the view "contact" in the other view template
$this->load->view('template', $data);
In view template.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
<head>
<title>Template codeigniter</title>
</head>
<body>
<div>
<?=$body?>
</div>
<div class="clear"></div>
<div>Footer</div>
</div>
</body>
</html>
$body is the view contact.
But now I face a problem. The form validation doesn't work if I pass the form_view as string to $data['body']. Is there any way to work around it?
Thanks.
Try loading the body content within the template itself. This should allow you to be more selective with your output:
In controller:
// Set the path to body content inside the $data array
$data['path_to_body'] = 'pages/contact';
$this->load->view('template', $data);
In view template.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
<head>
<title>Template codeigniter</title>
</head>
<body>
<div>
<? $this->load->view($path_to_body) ?>
</div>
<div class="clear"></div>
<div>Footer</div>
</div>
</body>
</html>

Using the HTML Helper For Code Igniter

I have a few questions regarding the HTML Helper on the code igniter website.
http://codeigniter.com/user_guide/helpers/html_helper.html
It shows where you can echo out the doctype but then my thinking is you'd have to do the manual html code for like the head tag, body tag and title tag but it has the meta tag.
So what would be the point in doing this?
<?php echo doctype(); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php
echo meta('description', 'My Great site');
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
?>
</head>
<body>
</body>
</html>
In a model pop those meta tags into an array and sent it to your view. Then use a foreach to output your meta tags, and wha-la many lines of meta turn into one line of php, and your meta tags can easily be edited in your model.

Resources