player display first part of cartel

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-07 18:08:28 +01:00
parent efac93e50d
commit 608e9f6ae2
14 changed files with 343 additions and 75 deletions
@@ -14,7 +14,8 @@ function edlp_ajax_node_theme($existing, $type, $theme, $path) {
'edlp_ajax_node' => array(
'file' => 'includes/edlp_ajax_node.inc',
'variables' => array(
'node' => NULL
'node_object' => NULL,
'view_mode' => 'default'
),
),
);
@@ -7,17 +7,19 @@
# @License: GPL-V3
edlp_ajax_node.node:
path: '/edlp/node/{nid}'
path: '/edlp/node/{nid}/{viewmode}'
defaults:
_controller: '\Drupal\edlp_ajax_node\Controller\EdlpAjaxNodeController::node'
_title: 'Node'
viewmode: 'default'
requirements:
_permission: 'access content'
edlp_ajax_node.ajaxnode:
path: '/edlp/node/{nid}/ajax'
path: '/edlp/node/{nid}/ajax/{viewmode}'
defaults:
_controller: '\Drupal\edlp_ajax_node\Controller\EdlpAjaxNodeController::nodejson'
_title: 'AjaxNode'
viewmode: 'default'
requirements:
_permission: 'access content'
@@ -8,5 +8,5 @@ function template_preprocess_edlp_ajax_node(&$vars){
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
*/
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$vars['node'] = $view_builder->view($vars['node'], 'default');
$vars['node'] = $view_builder->view($vars['node_object'], $vars['view_mode']);
}
@@ -14,11 +14,18 @@ class EdlpAjaxNodeController extends ControllerBase {
private function toRenderable(){
$this->query();
// dpm($this->future_nodes);
return array(
"#theme"=>'edlp_ajax_node',
'#node' => $this->node,
);
if($this->node){
return array(
"#theme"=>'edlp_ajax_node',
'#node_object' => $this->node,
'#view_mode' => $this->viewmode,
);
}else{
return array(
'#markup'=>'404! Node '.$this->nid." not found!"
);
}
}
/**
@@ -26,8 +33,9 @@ class EdlpAjaxNodeController extends ControllerBase {
*
* @return renderable array
*/
public function node($nid) {
public function node($nid, $viewmode) {
$this->nid = $nid;
$this->viewmode = $viewmode;
return $this->toRenderable();
}
@@ -36,16 +44,18 @@ class EdlpAjaxNodeController extends ControllerBase {
*
* @return json
*/
public function nodejson($nid) {
public function nodejson($nid, $viewmode) {
$this->nid = $nid;
$response = new JsonResponse();
$this->viewmode = $viewmode;
$renderable = $this->toRenderable();
$rendered = render($renderable);
$response = new JsonResponse();
$response->setData([
'test'=>'hello edlp ajax node',
'test' => 'hello edlp ajax node',
'nid' => $this->nid,
'rendered'=> $rendered
'view_mode' => $this->viewmode,
'rendered'=> $rendered,
]);
return $response;