View previous topic :: View next topic |
Author |
Message |
maxboost Smarty Rookie
Joined: 27 Mar 2014 Posts: 11
|
Posted: Thu Mar 27, 2014 10:31 pm Post subject: pages within smarty.net (newbie question) |
|
|
if i wanted to create pages "index.php?=vps" by using template file named "page_vps.tpl" using the name after "page_" and before ".tpl" to auto create page
how can this be done? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 28, 2014 12:16 am Post subject: |
|
|
You will want a key for that param such as:
Then use it in the call:
Code: | $smarty->display("page_{$_GET['page']}.tpl"); |
Of course, sanitize the GET input first. |
|
Back to top |
|
maxboost Smarty Rookie
Joined: 27 Mar 2014 Posts: 11
|
Posted: Fri Mar 28, 2014 1:37 pm Post subject: |
|
|
thank you, thank you
but getting a great blank page
i have made an template "page_home.tpl" and edit index.php with
$smarty->display("page_{$_GET['home']}.phtml"); |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 28, 2014 2:19 pm Post subject: |
|
|
If you made a template called "page_home.tpl"
and called
Code: | index.php?page=home |
and in PHP, use:
Code: | $smarty->display("page_{$_GET['page']}.tpl"); |
You should get the right template. I'm not sure why you are using .phtml when the template name is .tpl ? |
|
Back to top |
|
maxboost Smarty Rookie
Joined: 27 Mar 2014 Posts: 11
|
Posted: Fri Mar 28, 2014 2:22 pm Post subject: |
|
|
thank you i have changed it back to ".tpl"
question, do i replace
from
$smarty->display('page_home.tpl');
to
$smarty->display("page_{$_GET['page']}.tpl"); |
|
Back to top |
|
maxboost Smarty Rookie
Joined: 27 Mar 2014 Posts: 11
|
Posted: Fri Mar 28, 2014 2:23 pm Post subject: |
|
|
thanks for the help friend
http://test.switchmia.com/
still getting that blank page |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 28, 2014 2:25 pm Post subject: |
|
|
check your PHP log for errors, and turn on display errors in testing too. ALso you need to pass ?page=home in the URL if you are not doing that. If still blank and no errors, start debugging. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 28, 2014 2:26 pm Post subject: |
|
|
maxboost wrote: | thank you i have changed it back to ".tpl"
question, do i replace
from
$smarty->display('page_home.tpl');
to
$smarty->display("page_{$_GET['page']}.tpl"); |
You might try
$smarty->display('page_home.tpl');
first, see if the page comes up. If so, then get the value from the URL:
$smarty->display("page_{$_GET['page']}.tpl"); |
|
Back to top |
|
maxboost Smarty Rookie
Joined: 27 Mar 2014 Posts: 11
|
Posted: Fri Mar 28, 2014 2:27 pm Post subject: |
|
|
correct, does work when "$smarty->display('page_home.tpl'); " is usedbut not "$smarty->display("page_{$_GET['page']}.tpl");" |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 28, 2014 2:41 pm Post subject: |
|
|
maxboost wrote: | correct, does work when "$smarty->display('page_home.tpl'); " is usedbut not "$smarty->display("page_{$_GET['page']}.tpl");" |
And in the calling URL you have:
?page=home
You need that. |
|
Back to top |
|
maxboost Smarty Rookie
Joined: 27 Mar 2014 Posts: 11
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 28, 2014 3:10 pm Post subject: |
|
|
what does this show?
echo "page_{$_GET['page']}.tpl"; |
|
Back to top |
|
maxboost Smarty Rookie
Joined: 27 Mar 2014 Posts: 11
|
Posted: Fri Mar 28, 2014 3:12 pm Post subject: |
|
|
also blank :/ |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 28, 2014 3:13 pm Post subject: |
|
|
If that is blank, you have a PHP error. Check the php error log. |
|
Back to top |
|
maxboost Smarty Rookie
Joined: 27 Mar 2014 Posts: 11
|
Posted: Sat Mar 29, 2014 3:16 am Post subject: |
|
|
question
when adding "echo "page_{$_GET['page']}.tpl";" you like me to add that below
$smarty->display("page_{$_GET['page']}.tpl");
// $smarty->display("page_{$_GET['page']}.tpl");
// echo "page_{$_GET['page']}.tpl
just to confirm, because in my side i dont see any errors in the logs and i am a newbie to smarty |
|
Back to top |
|
|