Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1838598
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:29:58+00:00 2026-05-17T06:29:58+00:00

I’m just getting started with cakePHP, and things aren’t going so well so far.

  • 0

I’m just getting started with cakePHP, and things aren’t going so well so far.

I have a controller that handles confirming user emails. On registration the user is sent an email with a confirmcode in a link. Depending on the confirm code they give, the controller gives different text responses. One of these responses includes a hyperlink in order to log in.

I’m trying to use the Html helper, but although I’ve loaded it in $helpers at the top of the class, I an only make it work if I then use App::import, and then instantiate it.

It all seems overkill to simply make a hyperlink! How many times do I have to load the same class?

Wherever I look on the web it keeps telling me it’s a bad idea to use a helper in a controller, but how else am I supposed to get the link made?

So I have

var $helpers = array('Html');

at the top of the controller, and:

if (isset($this->User->id)) { // Check the user's entered it right
  // Do some stuff to remember the user has confirmed
  // This is to load the html helper - supposedly bad form, but how else do I make the link?
  App::import('Helper', 'Html');
  $html = new HtmlHelper();
  $this->set('message', __("Your email address has been confirmed.", TRUE)." ".$html->link(__("Please log in", TRUE), array('controller' => "users", 'action' => "login" )));
} else {
  $this->set('message', __("Please check your mail for the correct URL to confirm your account", TRUE));
}

in the controller’s confirm method and

<div>
   <?php echo $message;?>
</div>

in the view to output the resulting message

Surely I’m going wrong somewhere – can anyone explain how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:29:59+00:00Added an answer on May 17, 2026 at 6:29 am

    The idea is that all the data you need to render the page is sent to the view with set, then any conditional logic or formatting is done in the view with helpers, so send whole query results when appropriate (suppose you need to alter a link to include the user’s screen name, you’ll have it handy).

    in controller action

    $this->set('user', $this->User);
    

    in view (this is slightly different depending on if your in <= 1.2 or 1.3

    if ($user->id) //available because of Controller->set
    {
        //1.2
        $link = $html->link(__("Please log in", TRUE), array('controller' => "users", 'action' => "login" ));
        //1.3
        $link = $this->Html->link(__("Please log in", TRUE), array('controller' => "users", 'action' => "login" ));
        echo __("Your email address has been confirmed.", TRUE)." $link";
    }
    else
    {
        $this->set('message', __("Please check your mail for the correct URL to confirm your account", TRUE));
    }
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.