5 * Contains paragraphs_demo.module
9 use Drupal\Core\Routing\RouteMatchInterface;
12 * Implements hook_help().
14 function paragraphs_demo_help($route_name, RouteMatchInterface $route_match) {
15 switch ($route_name) {
16 // Help for the paragraphs demo module.
17 case 'help.page.paragraphs_demo':
19 $output .= '<h3>' . t('About') . '</h3>';
20 $output .= '<p>' . t('The Paragraphs Demo module provides several <em>Paragraphs types</em> for the <a href=":paragraphs">Paragraphs module</a>, but no separate user interface. For more information, see the <a href=":online">online documentation for the Paragraphs module</a>.', [':online' => 'https://www.drupal.org/node/2444881', ':paragraphs' => Url::fromRoute('help.page', ['name' => 'paragraphs'])->toString()]) . '</p>';
21 $output .= '<h3>' . t('Uses') . '</h3>';
22 $output .= '<dt>' . t('Changing demo Paragraphs types') . '</dt>';
23 $output .= '<dd>' . t('Administrators can edit the provided <em>Paragraphs types</em> on the <a href=":paragraphs">Paragraphs types page</a> if the <a href=":field_ui">Field UI</a> module is enabled. For more information on fields and entities, see the <a href=":field">Field module help page</a>.', [':paragraphs' => Url::fromRoute('entity.paragraphs_type.collection')->toString(), ':field' => Url::fromRoute('help.page', ['name' => 'field'])->toString(), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? Url::fromRoute('help.page', ['name' => 'field_ui'])->toString() : '#']) . '</dd>';
24 $output .= '<dt>' . t('Deleting demo Paragraphs types') . '</dt>';
25 $output .= '<dd>' . t('The provided <em>demo Paragraph types</em> stay available even when the Paragraphs Demo module is uninstalled. They can be deleted individually on the <a href=":paragraphs">Paragraphs types page</a>.', [':paragraphs' => Url::fromRoute('entity.paragraphs_type.collection')->toString()]) . '</dd>';
32 * Implements hook_preprocess_node() for paragraph node templates.
34 * Attach css we need for paragraph demo content.
36 function paragraphs_demo_preprocess_node(&$variables) {
37 // If more general approach is needed then implement preprocessor for
38 // paragraph.html.twig.
39 if ($variables['node']->getType() === 'paragraphed_content_demo') {
40 $variables['#attached']['library'][] = 'paragraphs_demo/drupal.paragraphs_demo';