Delphi For PHP Forums       


Go Back   Delphi-PHP Forums > Delphi For PHP > VCL4PHP
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

VCL4PHP VCL for PHP. Questions or comments about the Visual Component Library for PHP, post them here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 23rd May 2009, 14:51
just Joined!
 
Join Date: Sep 2007
Posts: 4
Dorac is on a distinguished road
Question Smarty Template not working with {php} tags

Hi all, im very new to the Delphi4php so please bare with me if what i'm asking sounds like a really stupid question.

I have my application using smarty templates which is all fine and dandy, the components work and im happy with it. The problem is i need to have some php code on some of the pages to get my $_GETs which would allow me to show certain sections of my page.

Here is my template code for header.tpl

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>TimeDesign 1.0</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/css/default.css" type="text/css">
<link rel="stylesheet" href="/css/components.css" type="text/css">
{%$HeaderCode%}
</head>
<body>

{* this template includes a {php} block that assign's the variable $varX *}
{php}
   global $foo, $bar;
   if($foo == $bar){
     echo 'This will be sent to browser';
   }
  // assign a variable to Smarty
  $this->assign('varX','Toffee');
{/php}
{* output the variable *}
<strong>{$varX}</strong> is my fav ice cream :-)

{%$StartForm%}
<div id="wrapper">
<div id="title">My Test System</div>
<div id="navigation">
  <div id="navbar">{%$mnu_Navbar%}</div>
  <!-- TODO make this a component -->
  <div id="pagebar">
    <ul>
      <li><a href="">Master Table</a></li>
      <li><a href="">Educators</a></li>
      <li><a href="">Classes</a></li>
      <li><a href="">Rooms</a></li>
      <li><a href="">Rooms</a></li>
      <li><a href="">Subjects</a></li>
      <li><a href="">Layout</a></li>
      <li><a href="">Groups</a></li>
      <li><a href="">Solve It</a></li>
      <li><a href="">Reports</a></li>
      <li><a href="">Substitutions</a></li>
    </ul>
  </div>
</div>

<div id="header">
  <div id="left">&nbsp;</div>
  <div id="right">
    <table cellspacing="10">
      <tr>
        <td>{%$btn_Unlock_Headings%}</td>
        <td>{%$btn_Add_Period%}</td>
        <td>{%$btn_Add_Day%}</td>
      </tr>
      <tr>
        <td>{%$btn_Relabel_Headings%}</td>
        <td>{%$btn_Remove_Period%}</td>
        <td>{%$btn_Remove_Day%}</td>
      </tr>
    </table>
  </div>
</div>

<div id="middle_wrapper">

  {%include file="templates/sidebar.tpl"%}


    <div id="content">
index.tpl includes header.tpl and footer.tpl both of which I dont think is important to display here.

I did research on how to include php code in template files and was lead here
Smarty

It didn't work so I thought it was my smarty template version that was out of date so updated it... same problem.

My question to all you gurus out there is what am I doing wrong and how can I fix this so I may use php in my template files?

Really appreciate your help thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 23rd May 2009, 18:03
just Joined!
 
Join Date: Sep 2007
Posts: 4
Dorac is on a distinguished road
Default

Nevermind... figured it out.

In every tag you need to type any tag with {%tag%}

So I used

Code:
{%php%}

$bla bla = "bla bla";

{%/php%}

Hi look at this weird code: {%bla bla%} ... weird hey?
Which works
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 24th May 2009, 12:13
delphi-php's Avatar
Forum Admin
 
Join Date: Mar 2007
Location: London, UK
Posts: 599
delphi-php has a reputation beyond reputedelphi-php has a reputation beyond reputedelphi-php has a reputation beyond reputedelphi-php has a reputation beyond reputedelphi-php has a reputation beyond reputedelphi-php has a reputation beyond reputedelphi-php has a reputation beyond reputedelphi-php has a reputation beyond reputedelphi-php has a reputation beyond reputedelphi-php has a reputation beyond reputedelphi-php has a reputation beyond repute
Default

Glad you sorted it out Dorac!
__________________
Don't forget to add to a users reputation if they have helped you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 24th May 2009, 12:26
just Joined!
 
Join Date: Sep 2007
Posts: 4
Dorac is on a distinguished road
Default

Thanks, another problem I have though:

I am trying to include a smarty template file but using a php variable instead of a set name. This is of course in a smarty template file (header.tpl):

Code:
{%include file="templates/$page_name.tpl"%}
i also tried

Code:
{%include file="templates/$_GET['page'].tpl"%}
and

Code:
{%include file="templates/$_GET.page.tpl"%}
Arrays are referenced like this according to Smarty

What am i doing wrong though?

EDIT: Found solution on: Looking for a tutorial to use Smarty templates with D4PHP?

Last edited by Dorac; 24th May 2009 at 17:44. Reason: Found solution on another post
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 15th June 2009, 10:25
guy guy is offline
D4PHP User
 
Join Date: Mar 2009
Posts: 44
guy is on a distinguished road
Default

Hi,

Have you see the good example : "templates" in samples folder

I'm think you must include {%$HeaderCode%} {%$StartForm%} at start body {%$EndForm%} at end

Guy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 15th June 2009, 10:29
guy guy is offline
D4PHP User
 
Join Date: Mar 2009
Posts: 44
guy is on a distinguished road
Default

I'm find explain:

Component Writer's Guide :: Template Engines - Delphi for PHP Documentation Wiki

Guy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 23:01.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use