Reply
Smarty Template Question...
Old 05-05-2005, 10:52 PM Smarty Template Question...
Brian07002's Avatar
Webmaster Talker

Posts: 537
Name: Brian
Location: United States
Hi all,

I almost forgot to say that I am using Pinnacle Cart to make my website...

My question is basically this...Is it possible to use perl, cgi, php, or javascripts with the smarty template system but without creating a smarty plugin to use it? Another words I have tried adding a php scripts on on my homepage (in the usual way), and it didn't work. It seems you can't with the Smarty Template System. I hope I am wrong and their is a way around this. Meaning withouth having to create the plugin code.

Here's on of my missions:

I am trying to create the 'featured product' script that will random display a product from MYSQL database along with some other info. about that particular product and display it in a neatly formatted table on my homepage. Please help!! I am really trying to get into the groove with Smarty, but am having the "NooBlues".

Brian thanks you in advance!
He Really Does!
__________________
Millart's Wonderful World of Vector Art
http://millart.110mb.com/
Brian07002 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-05-2005, 11:05 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
PHP and Unicode with UTF-8
Posts: 3,111
Location: Toronto, Ontario
You wouldn't be able to use CGI since thats a separate technology, and Javascript is a client side programming language so nothing should stop it from working with Smarty.

Smarty has a {php}{/php} tag that allows you to use PHP within templates:
HTML Code:
<strong>Featured Product</strong>
{php}
$products = array(...);

$rand = mt_rand(0, count($products) - 1);

echo '<em>' . $products[$rand] . '</em>';
{/php}
This depends on the value of the $php_handling config value; you may have to alter this value to allow embedded PHP.
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 05-06-2005, 09:48 PM
Brian07002's Avatar
Webmaster Talker

Posts: 537
Name: Brian
Location: United States
Thank you for your help, but I am still having a problem getting it working. This is what the support guy at Pinnacle cart says:

The basic approach would be to create a Smarty plug-in script [ Smarty Online Documentation, Chapter 16 ].

The plug-in would perform a database query on the products table, and select a random product record. The plug-in would then assign the random record to a Smarty array which can be utilized in any of the Smarty template files.

In order to follow the convention for the rest of the cart, it would be advisable to create a Smarty template "box" that can be included on any page of the cart you desire.


Finally, the page(s) on which you want the box to appear, the template box gets included as {include file="boxtemplatefile.html"}.



Thank you for you time Chroder!

-Brian
__________________
Millart's Wonderful World of Vector Art
http://millart.110mb.com/
Brian07002 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Smarty Template Question...
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14097 seconds with 12 queries