On this page
Block theming overrides (7.x)
Last updated on
12 September 2019
This documentation is deprecated.
Getting inspired by documentation of custom modules and issue #569312, here is full process for applying a new simplenews block in a subtheme/custom module.
Process
Within simplenews.module (on line 2471), copy this existing schema:
function template_preprocess_simplenews_block(&$variables) {
global $user;
$tid = $variables['tid'];
// Set default values in case of missing permission.
$variables['form'] = '';
$variables['subscription_link'] = '';
$variables['newsletter_link'] = '';
$variables['issue_list'] = '';
$variables['rssfeed'] = '';
// Block content variables
$variables['message'] = check_plain(variable_get('simplenews_block_m_'. $tid, t('Stay informed on our latest news!')));
if (user_access('subscribe to newsletters')) {
$variables['form'] = drupal_get_form('simplenews_block_form_'. $tid);
$variables['subscription_link'] = l(t('Manage my subscriptions'), 'newsletter/subscriptions');
}
$variables['newsletter_link'] = l(t('Previous issues'), 'taxonomy/term/'. $tid);
$recent = simplenews_recent_newsletters($tid, variable_get('simplenews_block_i_'. $tid, 5));
$variables['issue_list'] = theme('item_list', $recent, t('Previous issues'), 'ul');
$term = taxonomy_get_term($tid);
$variables['rssfeed'] = theme('feed_icon', url('taxonomy/term/'. $tid .'/0/feed'), t('@newsletter feed', array('@newsletter' => $term->name)));
// Block content control variables
$variables['use_form'] = variable_get('simplenews_block_f_'. $tid, 1);
$variables['use_issue_link'] = variable_get('simplenews_block_l_'. $tid, 1);
$variables['use_issue_list'] = variable_get('simplenews_block_i_status_'. $tid, 0);
$variables['use_rss'] = variable_get('simplenews_block_r_'. $tid, 1);
// Additional variables
$variables['subscribed'] = empty($user->uid) ? FALSE : (simplenews_user_is_subscribed($user->mail, $tid) == TRUE);
$variables['user'] = !empty($user->uid);
}
Now, paste it to your themes' template.php file and rename the function to yourtheme__preprocess_simplenews_block.
Then, create a custom module and using hook_form_alter manage the new subscription form.
Here's an example of mycoolmodule.module:
function mycoolmodule_form_alter(&$form, $form_state, $form_id) {
if($form_id == 'simplenews_block_form_1') {
$form['submit']['#value'] = t('Subscribe');
}
Help improve this page
Page status: Deprecated
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion