Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constants not working v3.1.23 #28

Closed
Gemorroj opened this issue May 12, 2015 · 3 comments · Fixed by #30
Closed

constants not working v3.1.23 #28

Gemorroj opened this issue May 12, 2015 · 3 comments · Fixed by #30

Comments

@Gemorroj
Copy link

{if $smarty.const.SEA_IS_P_NAME === true && $f.p_id}
    //...
{/if}

compiled to

<?php if (@constant(''SEA_IS_P_NAME'')===true&&$_smarty_tpl->tpl_vars['f']->value['p_id']) {?>
   //...
<?php }?>

error: PHP Parse error: syntax error, unexpected 'SEA_IS_P_NAME' (T_STRING)

'' - is two single quotes.

@Stricted
Copy link
Contributor

no problem here
{if !$smarty.const.ENABLE_DEBUG}.min{/if}

.min

@Gemorroj
Copy link
Author

The problem appears if the constant is not defined.

index.php

<?php

require __DIR__ . '/smarty-3.1.23/libs/Smarty.class.php';

// !!!
//define('TEST_CONST', false);

class Template extends Smarty
{
    public function __construct()
    {
        parent::__construct();

        $this->setTemplateDir(__DIR__ . '/templates/')
            ->setCompileDir(__DIR__ . '/templates_c/')
            ->setConfigDir(__DIR__ . '/configs/')
            ->setCacheDir(__DIR__ . '/cache/');

        $this->compile_check = true;
        //$this->default_modifiers = array('escape:"htmlall"');
    }

}


$obj = new Template();
$obj->display('test.tpl');

templates/test.tpl

{if $smarty.const.TEST_CONST === true}
    success
{/if}

render ok

@Stricted
Copy link
Contributor

ok now i can confirm that
{if $smarty.const.TEST_CONST === true}success{/if}
compiled to

success

Parse error: syntax error, unexpected 'TEST_CONST' (T_STRING) in

i think its better to check with defined() previously if the constant is exist

uwetews added a commit that referenced this issue May 14, 2015
uwetews added a commit that referenced this issue May 14, 2015
think-mcunanan pushed a commit to think-mcunanan/smarty that referenced this issue Mar 22, 2023
…ing-type-of-slide_reservation-from-int-to-bit(1)

Redmine #5019 changing type of slide reservation from int to bit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants