where do I place my custom template files ?

A place for users and developers of the Xataface to discuss and receive support.

Postby yusif » Wed Dec 06, 2006 2:18 pm

Hi Steve,
I have created some classes in my application directory in the actions folder eg . ../../myapp/actions/current_assets.php.

The name of the class is actions_current_assets.php . Within the class I used Smarty display function to in order to display my template after passing whatever variables I needed. My template file (current_assets.html) is located in my applications template folder. I have a link on my apps page that points to the action class above like this http://localhost/dataface/demod/index.php?-actions=current_assets . Unfortunately, I get the following error

Fatal error: No template found for action 'current_assets'.On line 48 of file C:\Program Files\Apache Group\Apache2\htdocs\dataface\actions\default.php in function printstacktrace()
On line 742 of file C:\Program Files\Apache Group\Apache2\htdocs\dataface\Dataface\Application.php in function handle(Array)
On line 1093 of file C:\Program Files\Apache Group\Apache2\htdocs\dataface\Dataface\Application.php in function handlerequest()
On line 7 of file C:\Program Files\Apache Group\Apache2\htdocs\dataface\demod\index.php in function display()
in C:\Program Files\Apache Group\Apache2\htdocs\dataface\actions\default.php on line 48

Could you help me out. Please!!!!

Where should me template be?
yusif
 
Posts: 28
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed Dec 06, 2006 3:25 pm

Hi Yusif,

Your template should be located in the application's templates directory. ie:
/path.to.your.app/templates

You mention, though that you have done this, so there could be something else wrong. Can you post the portion of code where you display the template?

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby yusif » Thu Dec 07, 2006 4:43 am

Hi Steve,
The code below is the the class i created

class actions_current_assets{
/**
* This class pulls the financial information on the current assets in the company and displays it
*/

function handle(){
import('Smarty/Smarty.class.php');

$sql = "SELECT * FROM current_assets";
$results = mysql_query($sql);
$count = mysql_num_rows($results);


for($i=0;$i<$count;$i++){
mysql_field_seek($results,$i);
$row[$i] = mysql_fetch_assoc($results);


$totalCurrentAssets[$i] = $row[$i]['cashInBank'] + $row[$i]['acctsReceivable'] + $row[$i]['inventory'] + $row[$i]['prepaidExpenses'] + $row[$i]['otherCurrrAssets'];
$cashInBank[$i] = $row[$i]['cashInBank'];
$accountsReceivable[$i] = $row[$i]['acctsReceivable'];
$inventory[$i] = $row[$i]['inventory'];
$prepaidExpenses[$i] = $row[$i]['prepaidExpenses'];
$otherCurrentAssets[$i] = $row[$i]['otherCurrrAssets'];

switch($row[$i]['period']){
case "1" :
$period[$i] = "First Quarter";
break;
case "2":
$period[$i] = "Second Quarter";
break;
case "3":
$period[$i] = "Third Quarter";
break;

}


}

$currentAssetsParameters = new Smarty;


$currentAssetsParameters->assign('count', $count);
$currentAssetsParameters->assign('period', $period);
$currentAssetsParameters->assign('cashInBank', $cashInBank);
$currentAssetsParameters->assign('accountsReceivable', $accountsReceivable);
$currentAssetsParameters->assign('inventory', $inventory);
$currentAssetsParameters->assign('prepaidExpenses', $prepaidExpenses);
$currentAssetsParameters->assign('otherCurrentAssets', $otherCurrentAssets);
$currentAssetsParameters->assign('totalCurrentAssets', $totalCurrentAssets);

$currentAssetsParameters->display('current_assets.html');





}

}









Hi Yusif,

>

Your template should be located in the application's templates directory. ie:

>path.to.your.app/templates

>

You mention, though that you have done this, so there could be something else wrong. Can you post the portion of code where you display the template?

>

-Steve

yusif
 
Posts: 28
Joined: Wed Dec 31, 1969 5:00 pm

Postby yusif » Thu Dec 07, 2006 10:48 am

Hi Steve,
Thanks for your response. Actually I figured out that I should have named the class file "current_assets.php" and not actions_current_assets.php and that took the error off.

Honestly, dataface framework is just marvelous. We hope with time and effort it might be the no.1
web application standard in the near future. keep the good work up.

-Yusif
yusif
 
Posts: 28
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Thu Dec 07, 2006 1:39 pm

Thanks for the kind words..

One other note on your code above. The dataface API extends smarty to add some extra functionality and save you some code. Rather than include Smarty, instantiate a Smarty object and make all of those assign calls, you could just call df_display() with the variables in an associative array as the first parameter and the name of the template as the second.

e.g.:

Code: Select all
df_display(
  array(
    'count'=>$count,
    'period'=>$period,
    'cashInBank'=>$cashInBank,
    ...
    ),
  'current_assets.html'
  );


Best regards

Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 21 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved