Skip to content

Instantly share code, notes, and snippets.

@ForestMars
Last active August 29, 2015 14:04
Show Gist options
  • Save ForestMars/4e4d95f79dfd6807d520 to your computer and use it in GitHub Desktop.
Save ForestMars/4e4d95f79dfd6807d520 to your computer and use it in GitHub Desktop.
/**
* Include meta tags.
* Also how does this work without a valid argument?
*/
//drupal_add_html_head($variables, 'rendering_meta'); {
// Add a theme-specific css class to the body tag.
//$variables['attributes']['class'][] = 'twigtastic';
//}
/**
* hook_preprocess_node implementation.
*
*/
function twigtastic_preprocess_node(&$vars) {
}
/**
* hook_preprocess_page implementation.
*
*/
function twigtastic_preprocess_page(&$vars) {
echo"this is the fun part";
//echo(entity_view(entity_load('node', 2), 'full'));
$vars['foo']='barbaz';
/*
* drupal_add_html_head is mainly unchanged, but variable_get() is gone.
*/
$config = Drupal::config('system.site');
$site_name = $config->get('name');
$og_title=Drupal::config('system.site')->get('name') . ' | my page title' ;
echo 'og is ' . $og_title;
$og = drupal_add_html_head(array(
'#tag' => 'meta',
'#attributes' => array(
'property' => 'og:title',
'content' => $og_title,
),
), 'node');
$vars['twigtastic_css'] = array(
'#attached' => array(
'css' => array(
drupal_get_path('theme', 'twigtastic') . '/css/skel-noscript.css' => array(),
drupal_get_path('theme', 'twigtastic') . '/css/style.css' => array(),
drupal_get_path('theme', 'twigtastic') . '/css/style-desktop.css' => array(),
drupal_get_path('theme', 'twigtastic') . '/css/style-1000px.css' => array(),
drupal_get_path('theme', 'twigtastic') . '/css/style-mobile.css' => array(),
),
),
);
$vars['twigtastic_js'] = array(
'#attached' => array(
'js' => array(
drupal_get_path('theme', 'twigtastic') . '/js/config.js' => array(),
drupal_get_path('theme', 'twigtastic') . '/js/html5shiv.js' => array(),
drupal_get_path('theme', 'twigtastic') . '/js/jquery.dropotron.min.js' => array(),
drupal_get_path('theme', 'twigtastic') . '/js/jquery.min.js' => array(),
drupal_get_path('theme', 'twigtastic') . '/js/skel-panels.min.js' => array(),
drupal_get_path('theme', 'twigtastic') . '/js/skel.min.js' => array(),
),
),
);
/* Performance tweak to avoid db call to invoke libraries via hook_page_alter()
* You don't nee this if you have your corescripts properly cached.
*/
$libraries = array(
'#attached' => array(
'library' => array(
'twigtastic/twigtastic.corescripts',
),
),
);
drupal_render($libraries);
}
/**
* Add external css with hook_css_alter
*/
function twigtastic_css_alter(&$css) {
$theme_path = drupal_get_path('theme', 'twigtastic');
$googlefonts = 'http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600|Arvo:700';
$css[$googlefonts] = array(
'data' => $googlefonts,
'type' => 'external',
'every_page' => TRUE,
'media' => 'all',
'preprocess' => FALSE,
'group' => CSS_AGGREGATE_THEME,
'browsers' => array('IE' => TRUE, '!IE' => TRUE),
'weight' => -1,
);
$fontawesome = '//netdna.bootstrapcdn.com/font-awesome/4.0.1/css/font-awesome.min.css';
$css[$fontawesome] = array(
'data' => $fontawesome,
'type' => 'external',
'every_page' => TRUE,
'media' => 'all',
'preprocess' => FALSE,
'group' => CSS_AGGREGATE_THEME,
'browsers' => array('IE' => TRUE, '!IE' => TRUE),
'weight' => -2,
);
}
/**
* Implements template_preprocess_field().
*/
function twigtastic_preprocess_field(&$vars) {
// If the view mode is "excerpt" use <h3> for the field labels. Otherwise use <h2>.
$vars['heading'] = ($vars['element']['#view_mode'] == 'excerpt') ? 'h3' : 'h2';
$vars['classes_array'][] = drupal_html_class('is-excerpt');
}
/**
* Implements template_preprocess_region().
*/
function twigtastic_preprocess_region(&$variables) {
$variables['attributes']['class'][] = 'clearfix';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment