public function SimplesitemapCustomLinksForm::buildForm in Simple XML sitemap 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ SimplesitemapCustomLinksForm.php, line 36 - Contains \Drupal\simplesitemap\Form\SimplesitemapCustomLinksForm.
Class
- SimplesitemapCustomLinksForm
- SimplesitemapCustomLinksFrom
Namespace
Drupal\simplesitemap\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$sitemap = new Simplesitemap();
$setting_string = '';
foreach ($sitemap
->get_config('custom') as $custom_link) {
// todo: remove this statement after removing the index key from the configuration.
if (isset($custom_link['index']) && $custom_link['index'] == 0) {
continue;
}
$setting_string .= isset($custom_link['priority']) ? $custom_link['path'] . ' ' . $custom_link['priority'] : $custom_link['path'];
$setting_string .= "\r\n";
}
$form['simplesitemap_custom'] = array(
'#title' => t('Custom links'),
'#type' => 'fieldset',
'#markup' => '<p>' . t('Add custom internal drupal paths and their priorities to the XML sitemap.') . '</p>',
);
$form['simplesitemap_custom']['custom_links'] = array(
'#type' => 'textarea',
'#title' => t('Relative Drupal paths'),
'#default_value' => $setting_string,
'#description' => t("Please specify drupal internal (relative) paths, one per line. Do not forget to prepend the paths with a '/'. You can optionally add a priority (0.0 - 1.0) by appending it to the path after a space. The home page with the highest priority would be <em>/ 1</em>, the contact page with a medium priority would be <em>/contact 0.5</em>."),
);
$form['simplesitemap_custom']['simplesitemap_regenerate_now'] = array(
'#type' => 'checkbox',
'#title' => t('Regenerate sitemap after hitting Save'),
'#description' => t('This setting will regenerate the whole sitemap including the above changes.<br/>Otherwise the sitemap will be rebuilt on next cron run.'),
'#default_value' => FALSE,
);
return parent::buildForm($form, $form_state);
}