Package Data | |
---|---|
Maintainer Username: | cviebrock |
Maintainer Contact: | colin@viebrock.ca (Colin Viebrock) |
Package Create Date: | 2014-10-06 |
Package Last Update: | 2014-10-07 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-19 03:04:19 |
Package Statistics | |
---|---|
Total Downloads: | 4,910 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 5 |
Total Watchers: | 3 |
Total Forks: | 2 |
Total Open Issues: | 0 |
A Google News sitemap generator for Laravel 4.
Add the package to your composer.json
file:
'cviebrock/laravel-news-sitemap' => 'dev-master'
Add the service provider to app/config/app.php
'providers' => array(
...
'Cviebrock\LaravelNewsSitemap\ServiceProvider',
);
Publish the configuration file:
php artisan config:publish cviebrock/laravel-news-sitemap
// create a new sitemap instance
$sitemap = \App::make('Cviebrock\LaravelNewsSitemap\NewsSitemap');
// if it's not cached, then populate with entries
if (!$sitemap->isCached()) {
foreach (Posts::all() as $post) {
$extras = [];
$images = [];
foreach ($post->images as $image) {
$images[] = [
'loc' => $image->url,
'caption' => $image->caption
];
}
$extras['keywords'] = $post->topics->lists('name');
$this->sitemap->addEntry($post->url, $post->title, $post->published_at, $extras, $images);
}
}
// returns an XML response
return $sitemap->render();
Please use Github for bugs, comments, suggestions.
master
branch.laravel-news-sitemap was written by Colin Viebrock and released under the MIT License. See the LICENSE file for details.
Copyright 2014 Colin Viebrock