I’m trying to figure out where I need to locate the .php and .tpl files within cs-cart.
So I have some custom pages test.php and test.tpl and want to display then on certain category pages. I edited categories.tpl, it this seems to include the test.tpl file fine, but it does not return the variables from text.php.
{if $category_data.category_id == 5320} {* Category: Ink & Toner Finder *}
{include file="custom/test.tpl"} {* //Add custom page here *}
{else}
normal code here
{/if}
I have these test files taken from smarty.net
file: /skins/basic/customer/custom/test.tpl
User Information:
Name: {$name}
Address: {$address}
But my results have only
file: /skins/basic/customer/custom/test.php
$smarty->assign('name', 'george smith');
$smarty->assign('address', '45th & Harris');
// display it
$smarty->display('test.tpl');
?>
So when I click on the appropriate category my results are
User Information:
Name:
Address:
So I guess my test.php is not being found. What directory does the test.php file need to be?
I tried /include/customer/test.php and I edited it to test.php with $smarty->display(‘custom/test.tpl’);
And that didn’t work either. Thanks for your assistance.
- Put your test.php file into the “include/customer” directory.
- In the file change
$smarty->display('test.tpl');
TO
$smarty->assign('content','test');
3. In your “targets” directory, make a new “test.php” file with this code:
if ( !defined('IN_CSCART') ) { die('Access denied'); }
if (AREA == 'C') {
include CUSTOMER_DIR . 'test.php';
}
4. In your “config.php” file
BELOW
'graph' => TARGETS_DIR . 'graph.php',
ADD
'test' => TARGETS_DIR . 'test.php',
5. If you haven’t already create a “custom_templates” directory in your “SKIN/customer/” directory.
6. Put your “test.tpl” there.
7. In your “content.tpl”
BELOW
{elseif $content == "product_details"}
{include file="products_pages/product_details.tpl"}
ADD
{elseif $content == "test"}
{include file="custom_templates/test.tpl"}
8. Your new page is at "www.yoursite.com/index.php?target=test
I hope this makes sense.
Thanks a million for that, I can’t tell you how much this helped me out. I would have not been able to figure this out on my own with my reverse engineering techniques alone.
I make all your well written changes, so as to integrate my application, but now I look at my application, I realize it’s going to take some work to separate my php from my html. I guess I’ll be on the smarty site quite a bit.
I do realize that is the best way to do it, but I was wondering if could just do this in the mean time. I now the page works it I hit it directly, but if I do this
{if $category_data.category_id == 5320}
{php}
{include file="/myphpapp.php"}
{/php}
{else}
It fails with this kind of error (kind of hard to debut)
Parse error: syntax error, unexpected '=' in /home/topoffic/public_html/var/compiled/customer/%%46^46D^46D5FAC3%%categories.tpl.php on line 9
Thanks again
if you are doing {php} then in the include you don’t need the ‘file=’ if you are trying to use smarty to include the file, then you don’t need the {php} tags
Yeah, you would simply need to do this:
{if $category_data.category_id == 5320}
{php}
include "/myphpapp.php";
{/php}
{else}
Because the part between {php} and {/php} is supposed to be php code.