Jump to content

PHP Function Automatically

Angel Moral

Recommended Posts

$this -> context -> controller -> addJS($this -> _path . '/views/js/front.js');

add the JS code into the module's front.js which in turn has to be loaded by the module using the PS built in functions.

You need to study the PS or other modules code to understand how it supposed to work.

Link to comment
Share on other sites

i dont know where is module's front.js. I have not create a module, i created a controller in controllers/front/NadieController.php and i would link to call it in nadie.tpl. I resolve the error in syntax. Now my files look like this:

nadie.tpl (themes/classic/templates)

{extends file='page.tpl'}
{block name='page_title'}
<span class="sitemap-title">{l s='Plantilla descargable' d='Shop.Theme'}</span>
{block name='page_content_container'}
<p><label>Introduce ancho:</label> <input type="text" id="name" name="name" maxlength="8" size="10" /></p>
<p><label>Introduce alto:</label> <input type="text" id="name" name="name" maxlength="8" size="10" /></p>
<button onclick="myFunction()">Click me</button>

<p id="demo"></p>

function myFunction() {
  console.log("Entro myfuncion");
                type: 'POST',
                data: {action:'getPDF'},
                url: here i need to call NadieController,
                success: function (response) {



class NadieControllerCore extends FrontController

public $php_self = 'nadie';

public function initContent()
if(isset($_POST['action']) && !empty($_POST['action'])) {
    echo "<script>console.log( 'Entro IF' );</script>";
    $action = $_POST['action'];
    switch($action) {
        case 'getPDF' : getPDF();break;
        // ...etc...



public static function getPDF(){
$pdf = new FPDF('P','mm',array(20,10));



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...