Jump to content

[solved] how can I Call a custom controller action method from a link


jemmeli

Recommended Posts

index.php?controller=YOUR_CONTROLLER&action=example&token=922fb5c427f8abfa1eaf7aa175c9529b

 

 

then, in your code, you can create if condition like:

 

if ($_GET['action']=='example'){
 $this->yourexamplefunction();
}

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

thanks for information that my solution works for you B)

i marked this thread as solved

 

if you've got an y questions related to this topic - feel free to continue discussion here - solved isn't mean closed ;)

 

regards

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hello , 

 

i´ll try in class AdminOrdersController extends AdminOrdersControllerCore

 

and not works 

 

I call like

 

index.php?controller=AdminOrders&token=b25b78729e33e99c5359c54482392669&action=example

 

with form 

 

<form method="post" action="{$link->getAdminLink('AdminOrders')|escape:'htmlall':'UTF-8'}&action={$action|escape:'htmlall':'UTF-8'}">
    <input  type="submit" id="submitFunction" value="Actualize" name="submitFunction" class="button" >
 </form>

 

And in my controller code 


public function __construct()
{
if ($_GET['action']=='example'){
$this->function_example();
}else{
parent::__construct();
$this->_conf = $this->_conf + array(32 => $this->l('texto'));
}
 
}
 
Thanks
Edited by jbastarras (see edit history)
Link to comment
Share on other sites

  • 6 months later...

index.php?controller=YOUR_CONTROLLER&action=example&token=922fb5c427f8abfa1eaf7aa175c9529b

 

 

then, in your code, you can create if condition like:

 

if ($_GET['action']=='example'){
	 $this->yourexamplefunction();
} 

Hello. 

Where should I put this code? 

I'am trying to add showdetails method in productList (back office).

I put 'showdetails' rowAction in AdminProductsController in renderList() method and write displayShowDetailsLink() method in HelperList.php.

 

public function displayShowDetailsLink($token = null, $id, $name = null)

{

$tpl = $this->createTemplate('list_action_details.tpl');

if (!array_key_exists('Details', self::$cache_lang))

self::$cache_lang['Details'] = $this->l('Details', 'Helper');

 

$ajax_params = $this->ajax_params;

if (!is_array($ajax_params) || !isset($ajax_params['action']))

$ajax_params['action'] = 'details';

 

$tpl->assign(array(

'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&showdetails'.$this->table.'&token='.($token != null ? $token : $this->token),

'action' => self::$cache_lang['Details'],

'id' => $id

));

return $tpl->fetch();

}

 

I think it should be work but i don't know where place the showdetails action.

 

Best Regards

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...