Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

pages within smarty.net (newbie question)
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
maxboost
Smarty Rookie


Joined: 27 Mar 2014
Posts: 11

PostPosted: Thu Mar 27, 2014 10:31 pm    Post subject: pages within smarty.net (newbie question) Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Mar 28, 2014 12:16 am    Post subject: Reply with quote

You will want a key for that param such as:

Code:
index.php?page=vps


Then use it in the call:

Code:
$smarty->display("page_{$_GET['page']}.tpl");


Of course, sanitize the GET input first.
Back to top
View user's profile Send private message Visit poster's website
maxboost
Smarty Rookie


Joined: 27 Mar 2014
Posts: 11

PostPosted: Fri Mar 28, 2014 1:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Mar 28, 2014 2:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
maxboost
Smarty Rookie


Joined: 27 Mar 2014
Posts: 11

PostPosted: Fri Mar 28, 2014 2:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
maxboost
Smarty Rookie


Joined: 27 Mar 2014
Posts: 11

PostPosted: Fri Mar 28, 2014 2:23 pm    Post subject: Reply with quote

thanks for the help friend

http://test.switchmia.com/

still getting that blank page
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Mar 28, 2014 2:25 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Mar 28, 2014 2:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
maxboost
Smarty Rookie


Joined: 27 Mar 2014
Posts: 11

PostPosted: Fri Mar 28, 2014 2:27 pm    Post subject: Reply with quote

correct, does work when "$smarty->display('page_home.tpl'); " is usedbut not "$smarty->display("page_{$_GET['page']}.tpl");"
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Mar 28, 2014 2:41 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
maxboost
Smarty Rookie


Joined: 27 Mar 2014
Posts: 11

PostPosted: Fri Mar 28, 2014 2:43 pm    Post subject: Reply with quote

shows blank

http://test.switchmia.com/?page=home
http://test.switchmia.com/index.php?page=home
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Mar 28, 2014 3:10 pm    Post subject: Reply with quote

what does this show?

echo "page_{$_GET['page']}.tpl";
Back to top
View user's profile Send private message Visit poster's website
maxboost
Smarty Rookie


Joined: 27 Mar 2014
Posts: 11

PostPosted: Fri Mar 28, 2014 3:12 pm    Post subject: Reply with quote

also blank :/
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Mar 28, 2014 3:13 pm    Post subject: Reply with quote

If that is blank, you have a PHP error. Check the php error log.
Back to top
View user's profile Send private message Visit poster's website
maxboost
Smarty Rookie


Joined: 27 Mar 2014
Posts: 11

PostPosted: Sat Mar 29, 2014 3:16 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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
Protected by Anti-Spam ACP