Search code examples
phpsmarty

What's the `{$smarty.server.PHP_SELF}?action=bulkdomain` means in smarty template?


I am reading a smarty project code, there is a .tpl file, and in it there is a form, its action is {$smarty.server.PHP_SELF}?action=bulkdomain:

<form method="post" action="{$smarty.server.PHP_SELF}?action=bulkdomain">
...

what is this mean?

Does it means submit this request to the .tpl's corresponding .php file? but how about the .php file the function like? because the php code is close sourced, I can not get it.


EDIT-01

I mean, in the template, use the action="{$smarty.server.PHP_SELF}?action=bulkdomain" for assigning the request method.

how about the request method should be in the template corresponding php file?

should it like this?

<?php

function bulkdomain($params)
{
    ...
}

EDIT-02

In the current running php file:

<?php

require($_SERVER['DOCUMENT_ROOT'] . '/smartyHeader.php');
$smarty->registerPlugin('block' ,'hsp', 'test1');

$smarty->assign('foo', 'Foo');

$smarty->display('php/test.tpl');

if there submit the data, whether I will write the code in the php file like this?

<?php

require($_SERVER['DOCUMENT_ROOT'] . '/smartyHeader.php');
$smarty->registerPlugin('block' ,'hsp', 'test1');

$smarty->assign('foo', 'Foo');

$smarty->display('php/test.tpl');

// accept the code
$action =$_GET['action']

whether I accept the action like upper writing code?


Solution

  • $smarty.server.PHP_SELF is the same as $_SERVER['PHP_SELF'] variable - means name of PHP file that currently running.

    If you want to process you form which have action="{$smarty.server.PHP_SELF}?action=bulkdomain" you can just check if exists global $_GET variable with key "action" and value "bulkdomain", for example:

    if(isset($_GET['action']) && $_GET['action']=='bulkdomain') {
        // do smt
    }