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 8371069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:04:33+00:00 2026-06-09T14:04:33+00:00

I am still learning PHP so my question may seem a little obvious but…

  • 0

I am still learning PHP so my question may seem a little obvious but…

My question relates to opencart but is probably quite a common practice on many websites. I am creating a opencart module and in that module i have several buttons that complete different tasks. Now I have assigned the button the correct ‘href’ with the path and appropriate action. eg

$this->data['dosomething'] = $this->url->link('module/modulename/dosomething', 'token=' . $this->session->data['token'], 'SSL');

Note: I have called the module and action a general name for the purposes of my question.

In the controller I then have a private function called ‘index’, followed by a private function called ‘dosomething’ like below

public function index() {

* insert code *

}

public function dosomething() {

*insert code*

$this->redirect($this->url->link('module/modulename', 'token=' . $this->session->data['token'], 'SSL'));

}

Now, I would like to know how do I get the button to direct to the module controller and then run the ‘dosomething’ function. I could put something information in the link, ie action=dosomething and do it this way but most of opencart simply uses the text of the last / as the action. If I use the href stated above I get a error as it is trying to find the controller and template located in ‘module/modulename/dosomething’ rather than the controller and template located in ‘module/modulename’ USING the function ‘dosomething’.

I hope this makes sense. I see that many other scripts in opencart successfully use this method but I just cant figure out how? I am sure I missing something obvious.

  • 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-06-09T14:04:34+00:00Added an answer on June 9, 2026 at 2:04 pm

    What you are doing is correct. OpenCart’s framework will use the third piece of the route if specified as the method. If you try

    public function dosomething() {
        die('OK');
    }
    

    Then go to the url you’ve got, it should just show a blank white page with OK written on it. My guess is the error doesn’t actually relate to the controller being an issue, and more to do with something else you’ve done. Either that, or the method and the third part of the route aren’t a match, or the dosomething method isn’t public

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

Sidebar

Related Questions

This is more a learning question than coding, but I'm certain it's a common
I'm still learning JQuery (and as a result a little JavaScript) but I can't
i'm still learning php but have a solid grasp on the basics and am
I'm sorry if this is a very simplistic question but I'm still learning the
I'm still learning php and have run up against what should be a relatively
So, I'm still new with the php coding, still learning, etc. So, if this
Still learning CSS so pardon if this is obvious - I am building a
I am currently still learning PHP so some things I still struggle with. I
I am not an expert in PHP, still learning it. I'd like some hints
I am still learning to make a Joomla component, but I have run into

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.