简体   繁体   中英

Drupal 6 : Redirect after form submit to display a block

Its been some time away from Drupal so here it goes:

I have a form that takes the user input (a keyword) and after that should display the latest tweets based on the keyword. Hence i am using twitter pull module..

function tweet_message_form() {
    $form['tweet_message'] = array(
        '#type' => 'textfield',
        '#title' => t('Fetch Tweets'),
        '#default_value' => variable_get('tweet_message', 'Keyword'),
    );

    //Submit button:
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Save Message'),
    );

    return $form;
}

Now inside the tweet_message_form_submit($form, &$form_state) function what should i write? I want to display a block when the form is submitted.

The block code is

<?php if (function_exists('twitter_pull_render')) { print twitter_pull_render('**keyword_entered**', '', 10); } ?>

I want to pass the value of keyword to this block from the form submit.So what should be the code inside the form submit? Not the exact code but some hints or tutorial links.

Well, you need to create a page (or just URL) to go to after you submit the form. let's say it's at "/example/thankyou"

In your function where you define the form, you can say:

$form["#redirect"] = "example/thankyou";

Or, in your submit handler, you can say:

drupal_goto("example/thankyou");

To pass information, in your submit handler you could always store the value in a SESSION variable, or just make it part of the URL...

drupal_goto("example/thankyou/THEVALUEGOESHERE");
$form["#redirect"] = "example/thankyou";

drupal_goto()可能不会保存所有数据

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM