This repository was archived by the owner on Sep 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Learn the API
Mario Bašić edited this page Apr 12, 2015
·
24 revisions
I'd like to show you how to use the API for each class: Sitemap
, Sitemap Index
, Url
and UrlSet
.
This is the class that you would want to use if you were creating a sitemap index.
use Laravelista\Bard\SitemapIndex;
use Sabre\Xml\Writer;
$sitemapIndex = new SitemapIndex(new Writer);
This will add a sitemap to sitemap index.
-
$location
is required and it must be a valid URL. -
$lastModification
is optional and you can use Carbon to set the date.
$sitemapIndex->addSitemap('http://acme.me/sitemap-tags.xml');
This method also return the instance of class Sitemap
. If you want to know what you can do with that instance see here.
Example:
$tags= $sitemapIndex->addSitemap('http://acme.me/sitemap-tags.xml');
You will probably not use this method, but if you insist you will get the sitemap index XML output in string type.
return $sitemapIndex->generate();
Now this is a method that you will want to use. It returns XML response.
return $sitemapIndex->render();
This class is only used from SitemapIndex
class as a returned object from addSitemap
method. See above.
This will validate given URL and set it as sitemap location.
$tags->setLocation('http://acme.me/sitemap-tags-index.xml');
- The cool image with Bard flying and Bard logo are from Bard, the Wandering Caretaker revealed website.