You are here

function ajax_links_api_help in Ajaxify Drupal with JQuery Ajax 8

Same name and namespace in other branches
  1. 6 ajax_links_api.module \ajax_links_api_help()
  2. 7 ajax_links_api.module \ajax_links_api_help()

Implements hook_help().

File

./ajax_links_api.module, line 35
Make any links or create new links via jQuery Ajax.

Code

function ajax_links_api_help($route_name, RouteMatchInterface $route_match) {
  $ajax_links_api_settings_url = Url::fromRoute('ajax_links_api.admin_settings');
  $ajax_links_api_demo_url = Url::fromRoute('ajax_links_api.demo');
  $output = '<h2><strong>How to use Ajax links API</strong></h2>';
  $output .= t('<p><strong>Method 1</strong> : You can ajaxify any links by specifying the Class/Id in @admin.', array(
    '@admin' => \Drupal::l(t('Module settings page'), $ajax_links_api_settings_url),
  ));
  $output .= ' Target DIV will be default Target DIV defined in module config page.</p>';
  $output .= '<p>' . t('Example : <code>@example1</code> . You can ajaxify this link by adding', array(
    '@example1' => '<a class="test" href="node/add/page">Add page</a>',
  ));
  $output .= '<code>.test</code> in module config page.</p>';
  $output .= '<p><strong>Method 2</strong> : Use this in your module,</p>';
  $output .= '<p><code>$service = \\Drupal::service("ajax_links_api.ajax_link");<br>';
  $output .= '$link = $service->lAjax($title, $path, $target, $link_options);</code></p>';
  $output .= '<p>* <code>$title</code>: Title to display.<br />';
  $output .= '* <code>$path</code> : Drupal path. <br />';
  $output .= '* <code>$target (optional)</code>: ID or CLASS of DIV to be replaced. You can override default Target DIV defined by specifying <code>$target</code>.</p>';
  $output .= '<p>Example : </p>';
  $output .= '<p><code>$service = \\Drupal::service("ajax_links_api.ajax_link");<br>';
  $output .= '$link = $service->lAjax("add page", "/node/add/page", "#content", array("#attributes" => "class" => array("ajax-links-api")));</code></p>';
  $output .= '<p><strong>Method 3</strong> : Add <code>class="ajax-link"</code> to any link. Target div will be Target DIV defined . You can change default Target DIV or override target by specifying attribute <code>rel=""</code>.</p>';
  $output .= '<p>' . t('Example : <code>@example2</code></p>', array(
    '@example2' => '<a class="ajax-link" href="node/add/page" rel="#content">Add page</a>',
  ));
  $output .= t('<h2>@demo</h2>', array(
    '@demo' => \Drupal::l(t('DEMO'), $ajax_links_api_demo_url),
  ));
  switch ($route_name) {
    case 'ajax_links_api.admin_settings':
    case 'help.page.ajax_links_api':
    case 'ajax_links_api.demo':
      return $output;
  }
}