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

{$smarty.cookies.username} in 5.0.0 rc2 #931

Open
markocrni opened this issue Feb 2, 2024 · 5 comments
Open

{$smarty.cookies.username} in 5.0.0 rc2 #931

markocrni opened this issue Feb 2, 2024 · 5 comments
Labels
waiting Waiting for answer

Comments

@markocrni
Copy link

markocrni commented Feb 2, 2024

Smarty 5.0.0 rc2, php 8.2.13
In template :
{$smarty.cookies.username} or
{$smarty.request.page}

Throws error:
'Call to undefined function Smarty\Compile\smarty_strtolower_ascii()', in file '/Smarty/Compile/SpecialVariableCompiler.php', at line 45

@wisskid
Copy link
Contributor

wisskid commented Feb 2, 2024

Well, the PHP docs state: "For functions and constants, PHP will fall back to global functions or constants if a namespaced function or constant does not exist." and the units indicatie this works perfectly. Somehow, it seems you have not loaded the 'functions.php' file, even though it is defined in composer.json autoload.files.

@wisskid wisskid added the waiting Waiting for answer label Feb 2, 2024
@markocrni
Copy link
Author

markocrni commented Feb 5, 2024

Thanks for your reply. Acutaly I don't use composer, because it's not an option for the project I'm working. I think it would be good if you post instructions on how to include Smarty without composer, because I believe there are more cases like mine.
My code for autoregistring and loading Smarty

AutoLoader::register(function ($sClassName) {
    if($sClassName === 'Smarty') {
        include( FWK_DIR . 'lib_tp/Smarty/Smarty.php');
        include( FWK_DIR . 'lib_tp/Smarty/functions.php');
        return;
    }
    $aParts = explode('\\', $sClassName);
    if((isset($aParts[0]) && $aParts[0] === 'Smarty')) {
        include( FWK_DIR . 'lib_tp/' . str_replace('\\', '/', $sClassName) . '.php');
    }
});

I'll do a little more research here...

@wisskid
Copy link
Contributor

wisskid commented Feb 5, 2024

can you explain why using composer is not an option?

@markocrni
Copy link
Author

The whole problem was that functions.php was not loaded.
I still think it would be nice if you post instructions on how to include Smarty without composer.

@wisskid
Copy link
Contributor

wisskid commented Mar 3, 2024

But you cannot explain why using composer is not an option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting for answer
Projects
None yet
Development

No branches or pull requests

2 participants