View previous topic :: View next topic |
Author |
Message |
limberjack Smarty n00b
Joined: 17 Mar 2016 Posts: 4
|
Posted: Thu Mar 17, 2016 4:49 pm Post subject: Smarty v2.6.6 doesnt generate .php form template - Err 404 |
|
|
Hello there, i am in bad situation so i want your help
i have to add new tab in HTML menu. The menu tabs are linked to .phps compiled with smarty v2.6.
I am noob with php and smarty either, so please dont be harsh!
For the test i just copied one of the templates rename it and link it in the menu. The templates are in dir /templates
I delete all files from template_c and all templates are compiled except newer one. So when i click on the new menu tab i am getting Error 404 Requested URL was not found - which is normal because i cant get .php from the new template
I have try to give rewrite permisions on apache2 and tried different options in Smarty.class.php - with no results
Is there some file where to give path to the specific template file (in Smarty.class.php the path to the templates and compiled files are OK) There is something that i am missing but i don't know what?
Please for your help!
Regards!
let me know if you need more information. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Mar 17, 2016 5:16 pm Post subject: |
|
|
Templates are not in the URL path. They are included by PHP. So your URL must go to a PHP file. |
|
Back to top |
|
limberjack Smarty n00b
Joined: 17 Mar 2016 Posts: 4
|
Posted: Fri Mar 18, 2016 11:33 am Post subject: |
|
|
mohrt wrote: | Templates are not in the URL path. They are included by PHP. So your URL must go to a PHP file. |
That is right the templates are not in URL link but the compiled phps.
The question is how to force smarty to compile new php from new template. The template (new_users.tpl) is located in /templates and the compiled php (%%some%number%%users.tpl.php) should be in /template_c. But when i open the web and try to open the URL new_users that should be linked to new_user.tpl.php, it shows me ERROR 404 URL not found
I have been trying to force compiling from Smarty.class.php but no success |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 18, 2016 2:15 pm Post subject: |
|
|
Quote: | But when i open the web and try to open the URL new_users that should be linked to new_user.tpl.php, it shows me ERROR 404 |
Where does new_user.tpl.php come from? That is not something Smarty creates. The smarty template is not something you directly link to. Normally you might have a php file such s new_user.php that does the following:
$smarty->display('new_user.tpl');
new_user.php would be something you would develop.
Now, it is possible to have a PHP script that dynamically loads a template file depending on the URL. Again, something you would develop, not something Smarty does itself. For example, the Smarty online documentation does this. |
|
Back to top |
|
limberjack Smarty n00b
Joined: 17 Mar 2016 Posts: 4
|
Posted: Fri Mar 18, 2016 4:50 pm Post subject: |
|
|
mohrt wrote: | Quote: | But when i open the web and try to open the URL new_users that should be linked to new_user.tpl.php, it shows me ERROR 404 |
Where does new_user.tpl.php come from? That is not something Smarty creates. The smarty template is not something you directly link to. Normally you might have a php file such s new_user.php that does the following:
$smarty->display('new_user.tpl');
new_user.php would be something you would develop.
Now, it is possible to have a PHP script that dynamically loads a template file depending on the URL. Again, something you would develop, not something Smarty does itself. For example, the Smarty online documentation does this. |
OK morht you got me now... i am sorry for my incomprehension in smarty... My basic problem is like alot young and untrained developers, the developed site is left for support to untrained web developer.
Lets talk about working web. I have this structure:
Code: | /webserver
/smarty
/libs
/internals
/plugins
Config_File.class.php
index.php
Smarty.class.php
Smarty_Compiler.class.php
debug.tpl
index.php
/templates
/cache
/configs
/templates
/methods
users.tpl
/templates_c
%%C2^C29^C29A4629%%users.tpl.php
index.php
.htaccess |
When i delete the content from/templates_c and log into menu users from the web browser. The content of /templates_c is back. Until now i though that smarty compile (generates) the .phps and what i need is to create .tpl file. Now i see that i was totally wrong.
I don't know where is users.php file.
Now i try to add another link that is called new_users, and i just copy/paste users.tpl and rename it to new_users.tpl and i did expect new_users.tpl.php to be compiled somehow in /templates_c....and it didn't work - so i am wrong as you said.
If i am understanding right i need to create new_users.php and use smarty functions to compile new_users.tpl. OK it's looks easy.
What about this %%C2^C29^C29A4629%%users.tpl.php file. I don't know how it is showed in /templates_c, but if i modify it and refresh the page the page will change.
Looks like i need some step by step tutorials, i am not even good in php but unfortunately i allready started....
Thanks mohrt, i owe you a beer!! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Mar 21, 2016 2:36 pm Post subject: |
|
|
The files in templates_c are automatically created by Smarty when a template is loaded. So for example, if you have a template named new_users.tpl and in somewhere in your PHP code you load that template:
$smarty->display('new_users.tpl');
Then the templates_c/new_users.tpl.php file is automatically generated. You rarely need to concern yourself with the files in templates_c directory. It is out of sight, out of mind. Smarty manages the files in there. You never directly create or access them, they are internal to Smarty.
So in your current PHP code, somewhere the users.tpl file gets loaded. If you create a new_users.tpl file, then somewhere in your PHP code you need to load it, likely similar to how users.tpl file is loaded. |
|
Back to top |
|
limberjack Smarty n00b
Joined: 17 Mar 2016 Posts: 4
|
Posted: Tue Mar 22, 2016 9:53 am Post subject: |
|
|
mohrt wrote: | The files in templates_c are automatically created by Smarty when a template is loaded. So for example, if you have a template named new_users.tpl and in somewhere in your PHP code you load that template:
$smarty->display('new_users.tpl');
Then the templates_c/new_users.tpl.php file is automatically generated. You rarely need to concern yourself with the files in templates_c directory. It is out of sight, out of mind. Smarty manages the files in there. You never directly create or access them, they are internal to Smarty.
So in your current PHP code, somewhere the users.tpl file gets loaded. If you create a new_users.tpl file, then somewhere in your PHP code you need to load it, likely similar to how users.tpl file is loaded. |
I came to this conclusion since the begining, but didnt find the .php which load the data into the templates. i have tried to find the person who created the website but he isnot developer in the company since 4-5 years and evein if i find him probably he will not remember what he have done.
So i am alone with your support. Thanks mohrt for the support, let me PM you and not to overload the thread. I will post the solution if we find one. |
|
Back to top |
|
|