Last active
August 27, 2015 05:36
-
-
Save rlnorthcutt/71155b292c6448bd7db1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- No PHP in the template, even though it has the PHP extension on the file. --> | |
<div class={{ classes }} pod"> | |
<div class="pod--inner"> | |
<h3>{{ title }}</h3> | |
{{ image }} | |
<p>{{ promo }}</p> | |
{{ link }} | |
<p><small>{{ terms }}</small></p> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is all angular. Consider this a total guess as to the angular code itself, | |
* but the process of grabbing the data from Drupal is straightforward. | |
*/ | |
var app = angular.module('myapp', []) | |
.controller('promoBlock', function($scope, $http, $log) { | |
$variables = Drupal.settings.promoBlock.variables; | |
// Now we can grab the values out of the object as necessary and do what we want | |
$title = $variables['title']; | |
// ... | |
// We can also call any external services, modify the values, add extra info, etc. | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Preprocess function for fieldable-panels-pane.tpl.php | |
* We are only using this to grab the information from the promo block widget | |
* and pass it to javascript. | |
*/ | |
function sprint_preprocess_fieldable_panels_pane(&$variables = array()) { | |
if ($variables->type == 'promo_block') { | |
// This is the bridge between PHP and JS | |
drupal_add_js(array("promoBlock" => $variables), 'setting'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment