View Full Version : droping PHP into Templates
Hi,
I've just started at my new job, and am learning the ilance system. I'm probably going about this the wrong way, but is it possible to drop some PHP into the templates (under Languages, Templates, static templates) for conditionals and includes etc?
Also, is there a form builder (probably wrong area to ask this) ? We're looking at building Landing pages and want to be able to trap e-mail addresses etc
happy to get the info out of a manual, if someone could point me in the right direction please
cheers,
Matt
Peter
12-07-2007, 01:12 PM
Hi Matt,
There is no method to let you write PHP inside the HTML templates. The ILance Framework will only want to parse html template {variables} which are in fact coming from the PHP. So a {variable} is actually $variable or $row['variable] in ILance when dealing with templates and those tags.
However, if the PHP code you wish to introduce is based on conditional expressions, (if, else, end if) you are allowed to write your conditionals as you see fit (right in the html templates).
For example:
<if condition="$_SESSION['ilancedata']['user']['user'] > 0">
Hello {user[username]}!
<else />
Hello Guest!
</if>
In order to see what session values are available to you simply type print_r($_SESSION) within the very end of ./functions/config.php just before the ?> ending php line. This will give you a large array of keys and values you are able to use dynamically in the HTML Templates.
To dig into the core PHP you'll need to edit the associated php script. Keep in mind it's not best practice to "hardcode" your changes so it's best to review our new API forum section which describes in details how to add new api hooks in the code and/or in templates so you and your client can upgrade to newer versions of ILance when it's released.
The manual goes into detail based on what's available in ILance. There is no developer API at the moment but we are working on it for early 2008.
Regards,
Peter
Hi Peter,
cool, thanks.... is there any way to have i includes (or should I set up the include files - html, as templates?) ?
basically I want to be able to d display custom forms depending on where the user has come from, using the PHP switch verb... so a link would have something like ./main.php?cmd=blah&cmd2=blahblah .... in the blah template would be the switch and include code (ie, blahblah.html)... am I spinning my wheels trying to get that to work within the template system, should I just set it up outside it, or is it possible to do ?
cheers
thanks Peter - is there a technical manual that might help me wrap my head around how to add php code to the templates? (I just read the API forum, t but I need some direcction on where to find the things I need to change in Admin)
i read this :
$somevar = 'this and that';
$ilance->template->pprint('main', array('somevar',.........);
Then you can use {somevar} in your html template.
: and I sort of get it... but I'm not familiar with th e variables you're using, so can't really put it all in context. Would I need to call a php script first, populate a variable (say, form1 = "<table><tr><td><form>...</form></table>" type thing), tthen call up a template, which references that variable ?
What I want to do is have a generic contact form that changes what fields it displays & submits depending on where the user has come from to end up there. Pretty straight forward in pure PHP, but I don't know how all these templates fit together, and how best to get in there and manipulate things while keeping it all in the s system , so to speak.
I guess what I really need is a developers manual or road map or something, please ;-)
cheers
Sunbum
01-22-2008, 09:07 PM
Hi Matt,
There is no method to let you write PHP inside the HTML templates. The ILance Framework will only want to parse html template {variables} which are in fact coming from the PHP. So a {variable} is actually $variable or $row['variable] in ILance when dealing with templates and those tags.
However, if the PHP code you wish to introduce is based on conditional expressions, (if, else, end if) you are allowed to write your conditionals as you see fit (right in the html templates).
For example:
<if condition="$_SESSION['ilancedata']['user']['user'] > 0">
Hello {user[username]}!
<else />
Hello Guest!
</if>
In order to see what session values are available to you simply type print_r($_SESSION) within the very end of ./functions/config.php just before the ?> ending php line. This will give you a large array of keys and values you are able to use dynamically in the HTML Templates.
To dig into the core PHP you'll need to edit the associated php script. Keep in mind it's not best practice to "hardcode" your changes so it's best to review our new API forum section which describes in details how to add new api hooks in the code and/or in templates so you and your client can upgrade to newer versions of ILance when it's released.
The manual goes into detail based on what's available in ILance. There is no developer API at the moment but we are working on it for early 2008.
Regards,
Peter
Hi Peter!
I just tried your example to peek at the session vars and was kind of "under whelmed" at the list ...
Has something majorly changed since you posted that?
Here is the result I got after I added the code:
Array
(
[ilancedata] => Array
(
[user] => Array
(
[lastseen] => 2008-01-22 17:44:55
[active] => no
[ipaddress] => 123.45.67.890
[browseragent] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
[referrer] => http://www.somesite.com/rfp.php?id=21036121
[rid] =>
[languageid] => 1
[slng] => eng
[styleid] => 1
[currencyid] => 1
)
)
)
Did I miss something?
Thanks!
ankaram
02-15-2008, 07:06 AM
hi peter give me ilance licens i need pls help me :)
??
Hi, have you already purchased the software? You show up as unlicensed, if so, please PM your license key and you should also be able to download from your members area.
Peter
02-15-2008, 04:45 PM
hi peter give me ilance licens i need pls help me :)
I can help and/or assist you only when you have purchased a valid ILance license.
Regards,
Peter
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.