I want to reload my site page before CakePHP redirects me to another page.

Asked 2 years ago, Updated 2 years ago, 93 views

In CakePHP, when you click a specific link,
Before displaying another page in a new window, I would like to reload the original page.
Is that possible?

/**UserController**/
public function hogehoge($user_id=0){
    // DB update processing is performed here
    $this->User->id=$user_id;
    $this->User->saveField('is_new', false);

    // Reload original page

    // Redirect to another page
    $this->redirect('http://hogehoge.jp');
}

Before performing the above processing, use the following description in View:
Launching a new window

<?php
    // Description in index.ctp
    $this->Html->link('GO', 'hogehoge/'.$user_id, array('target'=>'_blank'));
?>

cakephp

2022-09-30 21:16

1 Answers

Can you do that?
I can't.

However, there is a condition that says, "In the hogehoge method on the CakePHP side" as you mentioned in the code example.

When the hogehoge method is called in the form you describe, the browser interprets the response as for a "new window" and cannot embed instructions or information about the "original page" in it.

If you have the requirement to reload the original page (whether or not CakePHP) before viewing another page in a new window when you click on a specific link, you will have to use JavaScript on the original page side.

It's not that you shouldn't use JavaScript in CakePHP, but considering the code example in your question, I think it's a different topic.If you want to run from JavaScript in the original page, reloading the original page or displaying another page in a new window is not that much code.If you find something you don't understand after looking it up yourself, why don't you make another question thread at that time?


2022-09-30 21:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.