Skip to content

Commit

Permalink
Active routes check for routable objects. Updated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
BeneRoch committed Jun 27, 2018
1 parent b6973fb commit 5f1535d
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 177 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ $ composer require locomotivemtl/charcoal-contrib-sitemap

### Dependencies
- [Charcoal-factory][charcoal-app] ~0.8
- [Charcoal-factory][charcoal-factory] ~0.4
- [Charcoal-object][charcoal-object] ~0.4
- [Charcoal-translator][charcoal-translator] ~0.3

#### Required

Expand All @@ -64,8 +66,9 @@ properties are renderable by objects. Let's take the example below:
```json
{
"sitemap": {
"xml": {
"footer_sitemap": {
"l10n": true,
"check_active_routes": true,
"objects": {
"boilerplate/object/section": {
"label": "{{title}}",
Expand All @@ -91,10 +94,11 @@ properties are renderable by objects. Let's take the example below:
}
}
```
The `xml` sitemap is defined to be `l10n` (will output all languages as canonical) and defines
the `boilerplate/object/section` object to create the list. The section object has `children`,
in that case `boilerplate/object/section-children`, which will be output under the `boilerplate/object/section`
on the condition `isAnObjectParent` called on the parent.
The `footer_sitemap` sitemap is defined to be `l10n` (will output all languages as alternates) and defines
the `boilerplate/object/section` object to create the list. Note that is the object is of RoutableInterface,
it will automatically test the `isActiveRoute` condition. You can disable the option by setting `check_active_routes`
to `false` on the list. The section object has `children`, in that case `boilerplate/object/section-children`,
which will be output under the `boilerplate/object/section` on the condition `isAnObjectParent` called on the parent.

## Usage

Expand All @@ -113,7 +117,7 @@ Given the settings above:

```php
$builder = $container['charcoal/sitemap/builder'];
$sitemap = $builder->build('xml'); // xml is the ident of the settings you want.
$sitemap = $builder->build('footer_sitemap'); // footer_sitemap is the ident of the settings you want.
```

### Sitemap.xml
Expand Down
10 changes: 4 additions & 6 deletions src/Charcoal/Sitemap/Action/SitemapAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*/
class SitemapAction extends AbstractAction
{
use TranslatorAwareTrait;

/**
* @var string
*/
Expand Down Expand Up @@ -59,10 +57,10 @@ public function run(RequestInterface $request, ResponseInterface $response)
protected function toXml($map)
{
$str = '<?xml version="1.0" encoding="UTF-8"?><urlset '
. 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '
. 'xmlns:xhtml="http://www.w3.org/1999/xhtml" '
. '/>';

.'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '
.'xmlns:xhtml="http://www.w3.org/1999/xhtml" '
.'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
.'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"/>';

$xml = new SimpleXmlElement($str);

Expand Down
Loading

0 comments on commit 5f1535d

Please sign in to comment.