Skip to content

Instantly share code, notes, and snippets.

@ritcheyer
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritcheyer/8c1b85b647a0acd8009d to your computer and use it in GitHub Desktop.
Save ritcheyer/8c1b85b647a0acd8009d to your computer and use it in GitHub Desktop.
support.html.php
<?php
/**
* WEB-24978
* Show a max of 6 items
* If there are less than 6 items in any of the node queues, that becomes
* the max number that is displayed
*
* If there are more line items in any of the nodequeues beyond the maximum
* that should be shown, the extra ones are hidden.
*
* For the nodequeue columns that have hidden items, a "read more" link
* should be displayed.
*/
// Get the nodequeues necessary for this page
$nodequeue1 = views_get_view('nodequeue_1');
$nodequeue2 = views_get_view('nodequeue_2');
$nodequeue3 = views_get_view('nodequeue_3');
// Display dat block, yo (i actually have no idea what this does)
$nodequeue1->execute('block');
$nodequeue2->execute('block');
$nodequeue3->execute('block');
// Count number of items in each of the nodequeue
$count1 = count($nodequeue1->result);
$count2 = count($nodequeue2->result);
$count3 = count($nodequeue3->result);
// Get the smallest set from the nodequeues
$min = min($count1, $count2, $count3);
// If the minimum number of items in the nodequeue returned is greater
// than 6, we only want to display the first 6 initially.
if ($min > 6) {
$min = 6;
}
/**
* Format data as necessary
* Now that we have all our data, we want to format it correctly for final display
*
* @param object Node queue.
* @param int Minimum number of items to show.
* @return string Formatted html.
*/
function hide_links_after_minimum_in_group ($queue, $min_to_show) {
$return_set = '<ol class="article-list">';
foreach ($queue->result as $key => $node) {
if($key+1 > $min_to_show) {
$return_set .= '<li class="article-link is-hidden">';
} else {
$return_set .= '<li class="article-link">';
}
$return_set .= l($node->node_title, 'node/' . $node->nid);
$return_set .= '</li>';
}
$return_set .= '</ol>';
if (count($queue->result) > $min_to_show) {
$return_set .= '<p class="view-more">More articles</p>';
}
return $return_set;
}
// include_once('sites/all/themes/custom/tesla_theme/includes/support/support.html.php');
?>
<section class="support-articles">
<div class="container">
<div class="support-articles-learning">
<h2 class="section-subtitle"><a href="<?php print url('support/tagged/ordering'); ?>">Ordering</a></h2>
<?php print hide_links_after_minimum_in_group($nodequeue1, $min); ?>
</div>
<div class="support-articles-ordering">
<h2 class="section-subtitle"><a href="<?php print url('support/tagged/delivery'); ?>">Delivery</a></h2>
<ol class="article-list">
<?php print hide_links_after_minimum_in_group($nodequeue2, $min); ?>
</div>
<div class="support-articles-driving">
<h2 class="section-subtitle"><a href="<?php print url('support/tagged/owners'); ?>">Owners</a></h2>
<ol class="article-list">
<?php print hide_links_after_minimum_in_group($nodequeue3, $min); ?>
</div>
</div>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment