... | ... | @@ -10,17 +10,21 @@ Route::get('sitemap', function(){ |
|
|
// by default cache is disabled
|
|
|
$sitemap->setCache('laravel.sitemap', 3600);
|
|
|
|
|
|
// add item to the sitemap (url, date, priority, freq)
|
|
|
$sitemap->add(URL::to('/'), '2012-08-25T20:10:00+02:00', '1.0', 'daily');
|
|
|
$sitemap->add(URL::to('page'), '2012-08-26T12:30:00+02:00', '0.9', 'monthly');
|
|
|
|
|
|
// get all posts from db
|
|
|
$posts = DB::table('posts')->orderBy('created_at', 'desc')->get();
|
|
|
|
|
|
// add every post to the sitemap
|
|
|
foreach ($posts as $post)
|
|
|
// check if there is cached sitemap and build new only if is not
|
|
|
if (!$sitemap->isCached())
|
|
|
{
|
|
|
$sitemap->add($post->slug, $post->modified, $post->priority, $post->freq);
|
|
|
// add item to the sitemap (url, date, priority, freq)
|
|
|
$sitemap->add(URL::to('/'), '2012-08-25T20:10:00+02:00', '1.0', 'daily');
|
|
|
$sitemap->add(URL::to('page'), '2012-08-26T12:30:00+02:00', '0.9', 'monthly');
|
|
|
|
|
|
// get all posts from db
|
|
|
$posts = DB::table('posts')->orderBy('created_at', 'desc')->get();
|
|
|
|
|
|
// add every post to the sitemap
|
|
|
foreach ($posts as $post)
|
|
|
{
|
|
|
$sitemap->add($post->slug, $post->modified, $post->priority, $post->freq);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
|
... | ... | |