Jump to content

need help with include_php


Recommended Posts

Hi

 

How can I get this code working as all it is doing is showing this:

 

.tpl'}

 

there is the code I am using:

 

{include_php file='templates/orderforms/cart/footer/{$productgroup.name}.tpl'}

 

and I have :

 

hello this workes

 

in the file it is calling.

 

So what am I doing rong.

Link to comment
Share on other sites

No that did not work

 

what it is the file name I am calling is lets say hosting.tpl as this is the product group name in the cart so the is how I needed to call the file name {$productgroup.name}.tpl

 

and it is this that is not working right.

Link to comment
Share on other sites

I am trying to include some text from a tpl file at the bottom of the products.tpl (cart.php)

content area but it is deppent on the product group that is being used.

 

and using the smart code like this {$productgroup.name}.tpl should give the file name productgroupname.tpl.

Link to comment
Share on other sites

try including full path like for example

 

{include_php file='/home/USER-NAME/public_html/templates/orderforms/cart/footer/$productgroup.name.tpl'}

 

you may need to replace home and public_html. you will need to replace USER-NAME with your own

Link to comment
Share on other sites

Nop nether work's

 

but if I use this :

 

{include file='/home/kitchen2/public_html/templates/orderforms/cart/footer/productgroupname.tpl'}

 

It works but not when it is like:

{include file='/home/kitchen2/public_html/templates/orderforms/cart/footer/$productgroup.name.tpl'}

 

and Yes the group name has got a making named .tpl file.

Link to comment
Share on other sites

Here is the code I have in my cart/products.tpl

 

<link rel="stylesheet" type="text/css" href="templates/orderforms/cart/style.css" />

<br />

<p align="center" class="cartheading">{if $loggedin}<a href="{$smarty.server.PHP_SELF}?gid=addons">{$LANG.cartproductaddons}</a> | {/if}

{if $registerdomainenabled}<a href="{$smarty.server.PHP_SELF}?a=add&domain=register">{$LANG.registerdomain}</a> | {/if}

{if $transferdomainenabled}<a href="{$smarty.server.PHP_SELF}?a=add&domain=transfer">{$LANG.transferdomain}</a> | {/if}

<a href="{$smarty.server.PHP_SELF}?a=view">{$LANG.viewcart}</a>

</p>

 

{if !$loggedin && $currencies}

<form method="post" action="cart.php?gid={$smarty.get.gid}">

<p align="right">{$LANG.choosecurrency}: <select name="currency" onchange="submit()">{foreach from=$currencies item=curr}

<option value="{$curr.id}"{if $curr.id eq $currency.id} selected{/if}>{$curr.code}</option>

{/foreach}</select> <input type="submit" value="{$LANG.go}" /></p>

</form>

{/if}

<br />

 

<h2><strong>

{foreach key=num item=productgroup from=$productgroups}{if $gid eq $productgroup.gid}{$productgroup.name}{/if}{/foreach}

</strong></h2>

 

<table width="95%" border="0" cellpadding="10" cellspacing="0">

<tr>

<td>

{include_php file='templates/orderforms/cart/header/$productgroup.name.tpl'}

</td>

</tr>

</table>

<br />

 

 

<table class="data" width="95%" border="0" cellpadding="10" cellspacing="0">

<tr>

<th width="55%">Product Name / Description</th>

<th width="35%" align="left">Price Per Month</th>

<th width="10%"> </th>

</tr>

{foreach key=num item=product from=$products}

<tr class="pricing">

<td width="55%">

<strong>{$product.name}</strong><br />

{$product.description}

</td>

<td width="35%">

{if $product.paytype eq "free"}

{$LANG.orderfree}

{elseif $product.paytype eq "onetime"}

{$product.pricing.onetime} {$LANG.orderpaymenttermonetime}

{elseif $product.paytype eq "recurring"}

{if $product.pricing.monthly}{$product.pricing.monthly}<br />

{/if}

{if $product.pricing.quarterly}{$product.pricing.quarterly}<br />

{/if}

{if $product.pricing.semiannually}{$product.pricing.semiannually}<br />

{/if}

{if $product.pricing.annually}{$product.pricing.annually}<br />

{/if}

{if $product.pricing.biennially}{$product.pricing.biennially}<br />

{/if}

{/if}

</td>

<td width="10%"><input type="button" value="Buy Now"{if $product.qty eq "0"} disabled{/if} onclick="window.location='{$smarty.server.PHP_SELF}?a=add&pid={$product.pid}'" /></td>

</tr>

{/foreach}

</table>

<br />

<p align="center"><input type="button" value="{$LANG.viewcart}" onclick="window.location='cart.php?a=view'" /></p>

<br />

<table width="95%" border="0" cellpadding="10" cellspacing="0">

<tr>

<td>

{include file='/home/kitchen2/public_html/templates/orderforms/cart/footer/productgroupname.tpl'}

</td>

</tr>

</table>

<br />

<br />

 

and here is what I have in both cart/header/productgroupname.tpl and cart/footer/productgroupname.tpl

 

hello this workes
Link to comment
Share on other sites

html will be good all I need to pull in is a productgroup Description which is diffrent for each one and i have about 10 to 15 groups I need this for and that may change ether way.

 

but I still need to change the file name on the fly with the P/Group name or id would you have the code for that?

 

Thanks

Link to comment
Share on other sites

whmcs is in my the root of my domainname

 

then all files being used are in templates/orderforms/cart/ as a base.

 

then the page I need to include the custome code (productgroup Description) in is the products.tpl

 

and the custom "hello this workes " is in a folder named header or footer I made within the cart folder and each file in this folder will ether have the name or id of each productgroup i have within my whmcs.

 

but my problem is how within smarty can I dynamicly build a file name using smarty tag's?

 

ie

 

If I have a product group in my whmcs called blog hosting then I would also have a file named blog hosting.tpl or .html or .php with the Description for that group.

 

so when a client look at the proudct group of blod hosting the script will pull the description for that group.

 

so if

 

{$productgroup.name} = blog hosting

the file name need to be made is

 

$productgroup.name.tpl = blog hosting.tpl

 

if i just use blog hosting.tpl it works but I need this made with using tag's

Link to comment
Share on other sites

Sorry guys, my mind must have been elsewhere.

Put this at the very top of your products.tpl

{foreach key=num item=productgroup from=$productgroups}
{if $gid eq $productgroup.gid}{assign var=productgroupname value=$productgroup.name|replace:" ":""}{/if}
{/foreach}

Then use this anywhere within the rest of the products.tpl (no spaces in the name of your file to be included)

{include file="orderforms/cart/footer/$productgroupname.tpl"}

Edited by sparky
Link to comment
Share on other sites

Sorry guys, my mind must have been elsewhere.

Put this at the very top of your products.tpl

{foreach key=num item=productgroup from=$productgroups}
{if $gid eq $productgroup.gid}{assign var=productgroupname value=$productgroup.name|replace:" ":""}{/if}
{/foreach}

Then use this anywhere within the rest of the products.tpl (no spaces in the name of your file to be included)

{include file="orderforms/cart/footer/$productgroupname.tpl"}

 

Thank you for that it works.

 

You are just the best.

 

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated