Skip Navigation
Using named and unnamed parameters in custom controllers
Answer ID 10091   |   Last Review Date 03/18/2019

How should named and unnamed parameters be passed and referenced in custom controllers?


Oracle B2C Service (OSvC), all supported versions


When building a custom controller, you can either create a new one or add a function to the existing controller cp/customer/development/controllers/AjaxCustom.php.

Parameters can be passed when calling the controller as unnamed parameters or named parameters.

1. Unnamed parameters:
The the following URL would pass an unnamed parameters with the value of 42 when calling the function 'getDataForId' in the controller named 'data':

You would use the unnamed parameter in the controller like this:

function getDataForId($unnamedParam)
    // use the $unnamedParam in your code

2. Named parameters:
The following URL would pass a parameter named "meaning" and its associated value of 42 when calling the function 'getDataForId' in the controller named 'data':

You would use the named parameter in the controller ("data", in example above) like this:

function getDataForId()
    echo getUrlParm('meaning');

You would then reference the parameter like this:

function getDataForId()
    $namedParam = $this->input->post('meaning');
    // use the $namedParam in your code

For more information please consult the technical documentation linked below:
Answer ID 5169: Technical Documentation and Sample Code

Available Languages for this Answer:

Notify Me
The page will refresh upon submission. Any pending input will be lost.