Page 1 of 1

Inserting PhP scripts in a template

Posted: Sun Mar 26, 2006 6:18 pm
by Anduril
I am trying to create a login system in my cms template, but it the PHP scripts don't seem to work when I put them in a template. Am I doing something wrong?

Re: Inserting PhP scripts in a template

Posted: Sun Mar 26, 2006 6:39 pm
by Anduril
For example:

I want the login form to show up when your not logged in and the action should sent the information to the page himself. I haven the following script, it works on a normal site, but not in a cmsms template...:

Code: Select all

<?php if(!isset($_SESSION["login"])){ ?>
<table width="140" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="logintabel" align="center">
        <form name="loginform" method="post" action="<?php echo($_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']); ?>">
	Username:<br>
	<input name="loginusername" type="text"><br>
	Password:<br>
	<input name="loginpassword" type="password"><br>
	<input name="loginsubmit" type="submit" value="Login">
    </form>
	    <h3><a href="phpbb/index.php">Registreren!</a></h3></td>
  </tr>
</table>
<?php } ?>

Re: Inserting PhP scripts in a template

Posted: Sun Mar 26, 2006 7:03 pm
by pishkus
Create a User defined tag, place all your php code there, and insert into the template {your_tag_name}

Re: Inserting PhP scripts in a template

Posted: Sun Mar 26, 2006 7:20 pm
by Anduril
So I should create a user defined tag for every little piece of PHP?

Isn't there an other way? {php}{/php} or {literal}{/literal}

Re: Inserting PhP scripts in a template

Posted: Sun Mar 26, 2006 7:45 pm
by calguy1000
Yes, you can use {literal}{/literal} and for complex, multi-part php stuff, that may be the better way.

Re: Inserting PhP scripts in a template

Posted: Mon Mar 27, 2006 3:56 am
by Ted
For php code, you can use {php}{/php}.  However, in order for it to work, you need to set the allow_php_tags (I think?!? -- something close to that) value to true in config.php.

Re: Inserting PhP scripts in a template

Posted: Mon Mar 27, 2006 3:08 pm
by Anduril
OK, that's the solution:
For PHP to work in a template edit the config.php

$config['use_smarty_php_tags'] = true; (false = standard)

and then use {php} and {/php} to replace the tags

Thanx for the ideas.....

Re: Inserting PhP scripts in a template

Posted: Wed Jun 14, 2006 2:39 pm
by FrEdI
Hi all ! ;D

I would like to know, if we want to insert an enter in a sql database, we will use naturally php without any problems ?  ???

Tanks a lot. ;)

Re: Inserting PhP scripts in a template

Posted: Sat Jul 01, 2006 2:56 pm
by JohnR
Anduril wrote: $config['use_smarty_php_tags'] = true; (false = standard)

and then use {php} and {/php} to replace the tags
Cool, thanks for that. I was wondering and... my question is answered!