added prev next nav in perf nodes
This commit is contained in:
@@ -210,3 +210,114 @@ function perfart_init() {
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_block_info().
|
||||
*/
|
||||
function perfart_block_info() {
|
||||
$blocks = array();
|
||||
$blocks['perf_prevnext'] = array(
|
||||
'info' => t('Performance prev next btns'),
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_view().
|
||||
*/
|
||||
function perfart_block_view($delta='') {
|
||||
$block = array();
|
||||
|
||||
switch($delta) {
|
||||
case 'perf_prevnext' :
|
||||
$block['content'] = perf_prevnext_view();
|
||||
break;
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom function to assemble renderable array for block content.
|
||||
* Returns a renderable array with the block content.
|
||||
* @return
|
||||
* returns a renderable array of block content.
|
||||
*/
|
||||
function perf_prevnext_view() {
|
||||
global $language;
|
||||
|
||||
// get current perf nid
|
||||
$current_perf = menu_get_object();
|
||||
if ($current_perf && $current_perf->nid && $current_perf->type == 'performance') {
|
||||
// dsm($current_perf);
|
||||
// You have a valid node to work with.
|
||||
// get all perfs
|
||||
|
||||
$query = new EffectuationEntityFieldQuery;
|
||||
$result = $query->execute();
|
||||
$perfs = array();
|
||||
foreach ($result['node'] as $eff) {
|
||||
$eff = node_load($eff->nid);
|
||||
|
||||
if(!isset($eff->field_date_de_debut) || !isset($eff->field_performances))
|
||||
continue;
|
||||
|
||||
$debut = $eff->field_date_de_debut['und'][0]['value'];
|
||||
//1969/06/06-18:00
|
||||
$pattern = '/^(\d{4})\/?(\d{2})?\/?(\d{2})?-?(\d{2})?:?+(\d{2})?$/';
|
||||
preg_match($pattern, $debut, $debutMatches);
|
||||
if(!isset($debutMatches[1]))
|
||||
continue;
|
||||
|
||||
$perfadded = array();
|
||||
foreach ($eff->field_performances['und'] as $perf) {
|
||||
|
||||
if(in_array($perf['target_id'], $perfadded))
|
||||
continue;
|
||||
|
||||
$perfadded[] = $perf['target_id'];
|
||||
$perfs[] = $perf['target_id'];
|
||||
}
|
||||
}
|
||||
|
||||
dsm($perfs);
|
||||
|
||||
// get prev and next
|
||||
// build links
|
||||
$index = array_search($current_perf->nid, $perfs);
|
||||
dsm($index);
|
||||
$list = array();
|
||||
if($index > 0){
|
||||
$prev_nid = $perfs[$index-1];
|
||||
$prev = node_load($prev_nid);
|
||||
$prev_path = drupal_get_path_alias('node/'.$prev->nid, $language->language);
|
||||
$prev_link = l('< ' . $prev->title, $prev_path, array('html'=>true));
|
||||
$list['items'][] = array(
|
||||
'data' => $prev_link,
|
||||
'class' => array('perf-prev-link'),
|
||||
);
|
||||
}
|
||||
if ($index < count($perfs)-1) {
|
||||
$next_nid = $perfs[$index+1];
|
||||
$next = node_load($next_nid);
|
||||
$next_path = drupal_get_path_alias('node/'.$next->nid, $language->language);
|
||||
$next_link = l($next->title . ' >', $next_path, array('html'=>true));
|
||||
$list['items'][] = array(
|
||||
'data' => $next_link,
|
||||
'class' => array('perf-next-link'),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$list['attributes']['id'] = "perf-prev-next-btns";
|
||||
|
||||
dsm($list);
|
||||
|
||||
return theme('item_list', $list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ function perfart_get_performances(){
|
||||
$count = $count_query->count()->execute();
|
||||
pager_default_initialize($count, $limit);
|
||||
|
||||
foreach ($result['node'] as $eff) {
|
||||
foreach ($result['node'] as $eff) {
|
||||
$eff = node_load($eff->nid);
|
||||
//$eff = entity_load('node', array($eff->nid), NULL, FALSE);
|
||||
// dsm($eff, '$eff');
|
||||
@@ -445,7 +445,7 @@ function perfart_get_performances(){
|
||||
# filter artistes
|
||||
// $date['filters']['peoples'] = $personnes;
|
||||
|
||||
pager_default_initialize($count, $limit);
|
||||
// pager_default_initialize($count, $limit);
|
||||
|
||||
// $data[] = $date;
|
||||
|
||||
|
||||
@@ -2267,6 +2267,36 @@ html.classic-nav body.node-type-performance #main #center #content .node.type-pe
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
}
|
||||
html.no-js body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns,
|
||||
html.classic-nav body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns {
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
}
|
||||
html.no-js body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns li.perf-prev-link,
|
||||
html.classic-nav body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns li.perf-prev-link,
|
||||
html.no-js body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns li.perf-next-link,
|
||||
html.classic-nav body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns li.perf-next-link {
|
||||
flex: 1 1 100%;
|
||||
width: 50%;
|
||||
}
|
||||
html.no-js body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns li.perf-next-link,
|
||||
html.classic-nav body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns li.perf-next-link {
|
||||
text-align: right;
|
||||
}
|
||||
html.no-js body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns a,
|
||||
html.classic-nav body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns a {
|
||||
text-decoration: none;
|
||||
font-family: "MuseoSans", Arial, sans-serif;
|
||||
-moz-font-feature-settings: "calt=0,liga=0";
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
}
|
||||
@media screen and (min-width: 1201px) {
|
||||
html.no-js body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns a,
|
||||
html.classic-nav body.node-type-performance #block-perfart-perf-prevnext ul#perf-prev-next-btns a {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
body.node-type-document #main,
|
||||
.node-type-document-sonor #main,
|
||||
.node-type-object #main,
|
||||
|
||||
@@ -1070,7 +1070,25 @@ html.no-js, html.classic-nav{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#block-perfart-perf-prevnext{
|
||||
ul#perf-prev-next-btns{
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
li.perf-prev-link,
|
||||
li.perf-next-link{
|
||||
flex:1 1 100%;
|
||||
width: 50%;
|
||||
}
|
||||
li.perf-next-link{
|
||||
text-align: right;
|
||||
}
|
||||
a{
|
||||
text-decoration: none;
|
||||
.fs-filters-list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<!-- start article.node -->
|
||||
<article id="node-<?php print $node->nid; ?>" class="node type-<?php print $node->type; ?><?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " unpublished"; } ?>">
|
||||
<?php if ($page == 0 && isset($title)): ?>
|
||||
<h1 class="nodetitle">
|
||||
<?php $types = ['document', 'document_video', 'document_sonor', 'object']; // , 'effectuation' ?>
|
||||
<?php if (!in_array($node->type, $types)) : ?>
|
||||
<a href="<?php print $node_url?>"><?php print $title?></a>
|
||||
<?php else: ?>
|
||||
<?php print $title?>
|
||||
<?php endif; ?>
|
||||
</h1>
|
||||
<?php endif; ?>
|
||||
|
||||
<section class="content">
|
||||
<?php
|
||||
hide($content['comments']);
|
||||
hide($content['links']);
|
||||
print render($content);
|
||||
?>
|
||||
</section>
|
||||
|
||||
<?php if ($submitted): ?>
|
||||
<aside class="submitted">
|
||||
<?php print $submitted?>
|
||||
</aside>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($links = render($content['links'])): ?>
|
||||
<nav class="nav">
|
||||
<?php print $links; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
|
||||
</article>
|
||||
<!-- end article.node -->
|
||||
Reference in New Issue
Block a user