473,599 Members | 3,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

X-Cart/Smarty Custom PHP Scripts

162 New Member
i have what may be a very simple question for someone who has worked with X-Cart or Smarty.

I am adding a rollover image next to the category names in the main navigation. The following is my stripped down for this post version.
[php]
{foreach from=$categorie s item=c}

<div>

<div><img name="{$c.categ ory}_" src="{$ImagesDi r}/custom/paw.gif"></div>
<div><a href="home.php? cat={$c.categor yid}">{$c.categ ory}</a></div>

</div>

{/foreach}
[/php]I need to remove spaces in the names given at
Expand|Select|Wrap|Line Numbers
  1. name="{$c.category}_"
I want to make it
Expand|Select|Wrap|Line Numbers
  1. name="{str_replace(" ","_",$c.category)}_"
My attempts don't work and I get this error
Error: Smarty error: [in customer/categories.tpl line 26]: syntax error: unrecognized tag: str_replace(" ","_",$c.catego ry) (Smarty_Compile r.class.php, line 436) in C:\apache2triad \htdocs\clients \sitename.com\w ww\Smarty-2.6.12\Smarty.c lass.php on line 1095
My question is.. How can I make PHP functions work in X-Cart/Smarty?

I cant even find where $c.category is set. Thanks much.
Mar 17 '08 #1
1 1926
empiresolutions
162 New Member
Thanks Jay. Here's the solution-
Expand|Select|Wrap|Line Numbers
  1. {$c.category|replace:" ":""}
im now finding that slashes are not allowed either.
Expand|Select|Wrap|Line Numbers
  1. {$c.category|replace:" ":""|replace:"/":""}
works too. sweet.
Mar 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2302
by: Richard | last post by:
I need help. I have a smarty based program that I am modifying. I have a smarty template file that consists of smarty and HTML. I need to integrate some PHP database calls into it. My problem is I cannot figure out how to pass value between smarty and PHP. Going from php to smarty I've tried this: {php} $smarty = new Smarty; $smarty->assign("x", 100);
2
14159
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip Smarty-2.6.7.tar.gz on a system running WindowsXP SP2. Apache and PHP tested out fine. After adding Smarty, I ran the following http://localhost/testphp.php
1
2042
by: DJ Majestik | last post by:
OK, I am new to the whole PEAR/Smarty templating thing. I am trying to setup my directory structure correctly. If someone could weigh in and see if I have this setup "right", I would appreciate it. Directory structure: pear/ db/ db/ DB/ doc/
2
2603
by: M | last post by:
Hi Folks, I am trying to install Smarty using PHP 5 on a Windows XP PC using IIS v6 The following PHP File: <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head>
0
1577
by: Matt | last post by:
geez, i've done this a million times, you'd think i could get it right. uploading to production server for a new site, and part of the head.inc that starts everything up looks like this: echo SMARTY_DIR."Smarty.class.php<br>"; require_once(SMARTY_DIR."Smarty.class.php"); if (substr(phpversion(),0,1) == "4") { $smarty = new Smarty;
0
1235
by: lkrubner | last post by:
My boss gave me this assignment: "Change all the URLs on our website so that they no longer look like dynamic URLs. Make them look like folders." I spent all yesterday studying Apache mod_rewrite so now I think a url like this: http://www.mydomain.com/category/50/
2
3723
by: Man-wai Chang | last post by:
I meant something like: {section name=j start=0 loop=10 step=1} {php} $xx={$smarty.section.j.index}; echo $xx; {/php} {/section} -- iTech Consulting Services Limited Expert of ePOS solutions Website: http://www.itech.com.hk (IE only)
6
2553
by: alvarojaviervera | last post by:
Im programer (about 2 years ago I started), and allways I use PEAR. and Now I was thinking about change my tool for building custom dynamic sites. What do you think sholud be better Smarty, may be Pear or another one? Why? I need your comments and experience. Thanks 4 your time. Alvaro J Vera Alvarado VNC SFE.-
3
4107
by: deshaipet | last post by:
db2level = V97 FP 2. Oslevel = AIX 6.1 TL 03. TSAMP level = 3.1 FP 06 Hi, In todays world we have TSAMP HADR monitoring scripts which monitoring scripts to monitor failures in HADR system. But we dont get email alerts when a failover occured or when a instance is down and some other cases. questions :
0
7992
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8400
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8267
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5438
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3898
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3940
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2414
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1505
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.