Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitemap with laravel

I works in my project by LARAVEL.

I want to make sitemap. This is my controller:

class SitemapController extends BaseController {
        public function index() {
                header("Content-Type: text/xml;charset=utf-8");
                return View::make('sitemap');
        }
}

And This is my view sitemap.blade.php:

{{<?xml version="1.0" encoding="UTF-8" ?>}}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        <url>
                <loc>{{url()}}</loc>
                <priority>0.5</priority>
        </url>
        .
        .
        .
</urlset>

But result not appeared as XML. It appeared as a normal text.

like image 808
phper Avatar asked May 05 '14 09:05

phper


Video Answer


1 Answers

It works when I used:

{{'<?xml version="1.0" encoding="UTF-8" ?>'}}

and I updated my controller as:

class SitemapController extends BaseController {
        public function index() {
                $content = View::make('sitemap');
                return Response::make($content)->header('Content-Type', 'text/xml;charset=utf-8');
        }
}
like image 147
phper Avatar answered Sep 18 '22 11:09

phper