Skip to content

Instantly share code, notes, and snippets.

@druman
Created February 9, 2018 13:22
Show Gist options
  • Save druman/7c9ede20fc273bb5e59c40630cda1bd9 to your computer and use it in GitHub Desktop.
Save druman/7c9ede20fc273bb5e59c40630cda1bd9 to your computer and use it in GitHub Desktop.
Theming simplenews block
<div class="contact_form news-form">
<div class="container">
<div class="row">
<div class="col-sm-12 text-center">
<h2> <span class="icons-a"><img src="<?php print drupal_get_path('theme', 'bartik');?>/img/news-letter-icon.png" alt="icon"></span>
<?php print t("Newsletter");?></h2>
<p><?php print $heading;?> </p>
</div>
</div>
<div class="row contact_field">
<div class="sign-up-row clearfix">
<div class="snp-1">
<?php print $mail; ?>
</div>
<div class="snp-2">
<?php print $submit; ?>
</div>
</div>
</div>
</div>
</div>
<?php print $children; ?>
function bartik_theme() {
return array(
'simplenews_block_form_1' => array(
'render element' => 'form',
'template' => 'simplenews-block-form',
'path' => drupal_get_path('theme', 'bartik').'/templates',
),
);
}
function bartik_preprocess_simplenews_block_form_1(&$variables) {
// Shorten the form variable name for easier access.
$form = $variables['form'];
unset($form['mail']['#title']);
$form['mail']['#id'] = 'exampleInputEmail1';
$form['mail']['#attributes'] = array('class' => array('form-control'));
$form['mail']['#attributes']['placeholder'] = t('Enter Your Email');
$form['submit']['#value'] = t('Sign Up');
$form['submit']['#attributes'] = array('class' => array('licence_btn') );
$variables['heading'] = t('Sign up for our Newsletter to receive updates that will help you!');
// Create variables for individual elements.
$variables['mail'] = render($form['mail']);
$variables['submit'] = render($form['submit']);
// Be sure to print the remaining rendered form items.
$variables['children'] = drupal_render_children($form);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment