Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By n00b0101 on
I've been going through the forums and have tried just about every suggestion out there on how to theme the Simplenews block. Specifically, I'd like to change the value of the submit button and change the radios to a hidden field that defaults to "Subscribe".
I've tried mythemename_preprocess_simplenews_block, simplenews_block_form_alter, simplenews_block_1_form_alter, simplenews_block_simplenews-block-form-1_alter... none of them appear to have any affect at all... How can I alter the simplenews form in Drupal 6?
function mytheme_preprocess_simplenews_block(&$variables) {
global $user;
$form = array();
if ($user->uid) {
if (simplenews_user_is_subscribed($user->mail, $tid)) {
$submit_text = t('Unsubscribe');
$form['action'] = array('#type' => 'value', '#value' => 'unsubscribe');
}
else {
$submit_text = t('Subscribe');
$form['action'] = array('#type' => 'value', '#value' => 'subscribe');
}
$form['display_mail'] = array(
'#type' => 'item',
'#title' => t('User'),
'#value' => check_plain($user->name),
);
$form['mail'] = array('#type' => 'value', '#value' => $user->mail);
}
else {
$form['mail'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#size' => 20,
'#maxlength' => 128,
'#required' => TRUE,
);
$form['action'] = array(
'#type' => 'hidden',
'#value' => 'subscribe',
);
}
// All block forms use the same validate and submit function.
// #tid carries the tid for processing of the right newsletter issue term.
$form['#tid'] = $tid;
$form['#validate'][] = 'simplenews_block_form_validate';
$form['#submit'][] = 'simplenews_block_form_submit';
$form['submit'] = array(
'#type' => 'submit',
'#value' => isset($submit_text) ? $submit_text : t('Subscribe')
);
return $form;
}
Comments
You may try something like
You may try something like this :
1) copy the function from simplenews.module
function template_preprocess_simplenews_block(&$variables) {
....
variables defs
....
}
in your theme template,
2) then call it
function mytheme_preprocess_simplenews_block(&$variables) { }
3)then change some references to your own mysimplenews_customize.module, in which you put your custom functions, ...
Hope this helps.
Drupal Consultancy, Development & Training, Lyon, Paris, France, Suisse. https://chipway.com.
Theming SimpleNews Block
I made a nod with full process description.
I hope that will help.
http://drupal.org/node/859656
http://passivemanagement.net/
Using theme registry we can implement own html design for block
Form theme registry in template.php file
create simplenews-block-form.tpl.php file and add in theme directory "bartik/templates/simplenews-block-form.tpl.php"
Place your own html and put the variable, as show below-
filename: simplenews-block-form.tpl.php
Its done!
Its very simple way to implement simplenews signup block with own design.....@Vindesh