public function AjaxLinksApi::demo in Ajaxify Drupal with JQuery Ajax 8
Ajax links API Demo.
1 string reference to 'AjaxLinksApi::demo'
File
- src/
Controller/ AjaxLinksApi.php, line 50
Class
- AjaxLinksApi
- Ajaxify Drupal Link.
Namespace
Drupal\ajax_links_api\ControllerCode
public function demo() {
$account = $this
->currentUser();
$uid = $account
->id();
$userpath = $this->aliasManager
->getAliasByPath('/user/' . $uid);
$ajax_links_api_demo_url = Url::fromRoute('ajax_links_api.democontent');
$link_options = array(
'attributes' => array(
'class' => array(
'test',
),
'rel' => '.test1',
),
);
$ajax_links_api_demo_url
->setOptions($link_options);
$link1 = $this
->l('Click here', $ajax_links_api_demo_url);
$link2 = $this->ajaxLinksApiService
->lAjax('load this test page', '/ajax-links-api/test', '#content', array(
'attributes' => array(
'class' => array(
'ajax-links-api',
),
),
));
$link3 = $this->ajaxLinksApiService
->lAjax('User', $userpath, '.test2');
$ouptut = '<h2>Method 1 : load a test page </h2>(link with class="test" and rel=".test1". You can ajaxify this link by adding this link
class .test in admin settings):<br />' . $link1 . '<div class="test1"></div>';
$ouptut .= '<h2>Method 2 : load this test page </h2>(using lAjax):<br />' . $link2 . '';
$ouptut .= '<h2>Method 3 : Load profile </h2>(link with class="ajax-link" and rel=".test2"):<br />' . $link3 . '<div class="test2"></div>';
return array(
'#markup' => $ouptut,
);
}