Frontpage.php in Sitemap 2.0.x
File
src/Plugin/Sitemap/Frontpage.php
View source
<?php
namespace Drupal\sitemap\Plugin\Sitemap;
use Drupal\sitemap\SitemapBase;
use Drupal\Core\Url;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Link;
use Drupal\Core\Form\FormStateInterface;
class Frontpage extends SitemapBase {
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
$form['title']['#default_value'] = $this->settings['title'] ?: $this
->t('Front page');
$form['rss'] = [
'#type' => 'textfield',
'#title' => $this
->t('Feed URL'),
'#default_value' => $this->settings['rss'],
'#description' => $this
->t('Specify the RSS feed for the front page. If you do not wish to display a feed, leave this field blank.'),
];
return $form;
}
public function view() {
$title = $this->settings['title'];
$content[] = [
'#theme' => 'sitemap_frontpage_item',
'#text' => $this
->t('Front page of %sn', [
'%sn' => \Drupal::config('system.site')
->get('name'),
]),
'#url' => Url::fromRoute('<front>', [], [
'html' => TRUE,
])
->toString(),
'#feed' => $this->settings['rss'],
];
return [
'#theme' => 'sitemap_item',
'#title' => $title,
'#content' => $content,
'#sitemap' => $this,
];
}
}
Classes
Name |
Description |
Frontpage |
Provides a link to the front page for the sitemap. |