Skip to content

Commit

Permalink
Complete Recent Tutorials feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobroufa committed Apr 12, 2012
1 parent 9153436 commit 4da0feb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
13 changes: 7 additions & 6 deletions ba_module.module
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
/**
* Implement hook_entity_info_alter
*/

function ba_module_entity_info_alter(&$entity_info) {
$entity_info['node']['view modes']['recent_tutorials'] = array(
'label' => t('Recent Tutorials'),
'custom settings' => TRUE,
);
$entity_info['node']['view modes']['discover_tutorials'] = array(
'label' => t('Discover Tutorials'),
'custom settings' => TRUE,
);
}

/**
* Implement hook_block_info()
*/

function ba_module_block_info() {
$blocks['recent_tutorials'] = array(
'info' => t('Recent Tutorials'),
Expand All @@ -26,7 +28,6 @@ function ba_module_block_info() {
/**
* Implement hook_block_view()
*/

function ba_module_block_view($delta = '') {
$block = array();

Expand All @@ -38,7 +39,7 @@ function ba_module_block_view($delta = '') {
foreach ($terms as $tid) {
$result = NULL;
$query = new EntityFieldQuery;

$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'article')
Expand All @@ -52,7 +53,7 @@ function ba_module_block_view($delta = '') {
$results += entity_load('node', array_keys($result['node']));
}
}

shuffle($results);
$sliced = array_slice($results, 0, 10);
$view = entity_view('node', $sliced, 'recent_tutorials');
Expand All @@ -67,7 +68,7 @@ function ba_module_block_view($delta = '') {
}

/**
* Implement hook_theme()
* Preprocess recent_tutorials block
*/

function ba_module_theme() {
Expand Down
8 changes: 5 additions & 3 deletions tpl/recent_tutorials.tpl.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<div id="recent-tutorials">
<div class="recent-tutorials">
<a id="previous">Previous</a>
<div class="tutorial-list"><?php print $content ?></div>
<a id="next">Next</a>
<a id="previous" href="#">Previous</a>
<ul class="tutorial-list">
<?php print $content ?>
</ul>
<a id="next" href="#">Next</a>
</div>
</div>

0 comments on commit 4da0feb

Please sign in to comment.