|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
bosscunt Smarty n00b
Joined: 21 Sep 2016 Posts: 3
|
Posted: Wed Sep 21, 2016 2:57 pm Post subject: Win10 / XAMMP - Undefined index: Name in template |
|
|
Hello Forumers,
Apologies in advance if this appears as a total retard issue..
I am trying to resurrect some old php5 code for a text based rpg and smarty was recommended as the template engine. The issue here is that {$name} is not returning any values and I am being presented with some smarty template errors representing undefined index. <?php echo $_SESSION['username'];?> works fine.
Please do not hesitate to let me know if there are any further details required.
Quote: | Hello, {$name}!
this is my php line for php session username: bosscunt
Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\index.php on line 4
Title: Welcome To Smarty!
The current date and time is 2016-09-21 16:41:18
The value of global assigned variable $SCRIPT_NAME is /index.php
Example of accessing server environment variable SERVER_NAME: localhost
The value of {$Name} is
Notice: Undefined index: Name in C:\xampp\htdocs\smarty\templates_compile\3e8fe154245a2fdaea9fea4e0663b1125dfb722b_0.file.index.tpl.php on line 56
Notice: Trying to get property of non-object in C:\xampp\htdocs\smarty\templates_compile\3e8fe154245a2fdaea9fea4e0663b1125dfb722b_0.file.index.tpl.php on line 56
variable modifier example of {$Name|upper}
Notice: Undefined index: Name in C:\xampp\htdocs\smarty\templates_compile\3e8fe154245a2fdaea9fea4e0663b1125dfb722b_0.file.index.tpl.php on line 61
Notice: Trying to get property of non-object in C:\xampp\htdocs\smarty\templates_compile\3e8fe154245a2fdaea9fea4e0663b1125dfb722b_0.file.index.tpl.php on line 61
An example of a section loop:
none
An example of section looped key values:
testing strip tags
This is a test
This is an example of the html_select_date function:
This is an example of the html_select_time function:
This is an example of the html_options function:
Smarty Installation test...
Testing template directory...
C:\xampp\htdocs\smarty\templates is OK.
Testing compile directory...
C:\xampp\htdocs\smarty\templates_compile is OK.
Testing plugins directory...
C:\xampp\htdocs\smarty\libs\plugins is OK.
Testing cache directory...
C:\xampp\htdocs\smarty\cache is OK.
Testing configs directory...
C:\xampp\htdocs\smarty\configs\ is OK.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.
Hello, {$name}!
THIS IS MY PHP LINE bosscunt |
Line 56:
Code: | The value of {$Name} is <b><?php echo $_smarty_tpl->tpl_vars['Name']->value;?> |
Line 61:
Code: | <b><?php echo mb_strtoupper($_smarty_tpl->tpl_vars['Name']->value, 'UTF-8');?> |
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Sep 22, 2016 2:51 am Post subject: |
|
|
Why the hell do you address $smarty properties directly to begin with? |
|
Back to top |
|
bosscunt Smarty n00b
Joined: 21 Sep 2016 Posts: 3
|
Posted: Thu Sep 22, 2016 3:41 am Post subject: |
|
|
Hello AnrDaemon,
I appreciate your humbled and knowledgeable response.
As mentioned in my first post to the forum, I am "trying" <- (this is the keyword here) to resurrect some old php5 code. Why would I address smarty properties first? Well, if I can't get this to populate for something as simple as "name" it sure as &%#& isn't going to populate for anything else.
Could you try again at actually helping me, please?
Kind Regards, |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Sep 22, 2016 7:23 am Post subject: |
|
|
I don't know, what exactly your "resurrection" encompass, but you didn't provide the code anyone can test.
Just some bits that can only be guessed at.
Did you read Smarty documentation? Did you see its examples?
Smarty is no magic, it is a very strict and direct presentation layer. If you did not assign your $name anywhere to the document instance before rendering, of course it will be empty.
Not to mention, running PHP code from templates is not going to work. |
|
Back to top |
|
bosscunt Smarty n00b
Joined: 21 Sep 2016 Posts: 3
|
Posted: Thu Sep 22, 2016 10:59 am Post subject: |
|
|
AnrDaemon,
This may very well be resolved.
Bless you. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|