Support Forums

Using smarty variable with... variables

This is a discussion on Using smarty variable with... variables within the Technical Support forums, part of the Technical Support Forums category; Hi to everyone, I use a lot of smarty statment in my template, but I have a question. I want ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

Reply
 
Thread Tools Display Modes
Old 02-08-2010, 04:11 AM   #1
Customer
 
Join Date: Sep 2008
Posts: 51
Rep Power: 9
ronin is on a distinguished road
Default Using smarty variable with... variables

Hi to everyone,

I use a lot of smarty statment in my template, but I have a question.

I want to use (if possible) smarty variable with... variables..

I'll explain better: I have on my web site AdSense advertisement, but I really don't want to show this on some page.
Now.. problem is really easy to solve when the page I don't want ads have "standard" url.
Example, if I don't want ads on my index page, I wrote:

Code:
{if $smarty.server.REQUEST_URI == "/"}
NO ADS HERE
{else}
ADS CODE HERE
{/if}
Problem I try to solve is with page with variable.
Example, I want to remouve ads from ANY page of checkout process.

Is there any way to say
Code:
{if $smarty.server.REQUEST_URI == "/usercheckout.php?and_any_possible_variable_after_that?"}
{/if}
Thanks for reply!


What version of 68 Classifieds are you running?
V4.1.8 Developers
ronin is offline   Reply With Quote
Old 02-08-2010, 04:22 AM   #2
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 2,615
Rep Power: 64
seymourjames is a jewel in the rough
Default

{if $SCRIPT_NAME == "/usercheckout.php"}


I believe that will work.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68 Classifieds
seymourjames is offline   Reply With Quote
Old 02-08-2010, 04:34 AM   #3
Customer
 
Join Date: Sep 2008
Posts: 51
Rep Power: 9
ronin is on a distinguished road
Default

Thanks Seymourjames,

I'll try and I'll let you know!
ronin is offline   Reply With Quote
Old 02-08-2010, 04:44 AM   #4
Customer
 
Join Date: Sep 2008
Posts: 51
Rep Power: 9
ronin is on a distinguished road
Default

Yes, it works!

Thanks seymourjames, you save me a lot of headache !
ronin is offline   Reply With Quote
Old 02-08-2010, 04:52 AM   #5
Customer
 
Join Date: Sep 2008
Posts: 51
Rep Power: 9
ronin is on a distinguished road
Default

And... I have another question too.. (related, of course, to smarty statments..)

I have "only adult listings categories" where - of course - I don't want AdSense ads.

I wrote something similar:
Code:
{if $categoryname == "CATEGORY NAME 1"}
NO ADS HERE
{elseif $categoryname == "CATEGORY NAME 2"}
NO ADS HERE
{elseif $categoryname == "CATEGORY NAME 2"}
NO ADS HERE
---------
A LOT OF OTHER CATEGORY....
{/if}
Of course, this make page text (and weight..) very big...

Is there any way to say:

Code:
{if $categoryname == "CATEGORY NAME 1 // and CATEGORY NAME 2 // and CATEGORY NAME 3 // and so on?!"}
NO ADS HERE
{/if}
Thanks for reply!
ronin is offline   Reply With Quote
Old 02-08-2010, 05:14 AM   #6
Customer
 
Yasser's Avatar
 
Join Date: Mar 2009
Posts: 36
Rep Power: 6
Yasser is on a distinguished road
Default

Quote:
Originally Posted by seymourjames
{if $SCRIPT_NAME == "/usercheckout.php"}


I believe that will work.


will that work with v 4.1.2 ??


i have added the codes.. but didnt work?

__________________
v4.1.2 Developer -- default Template.
-----------------------------------------------
Yasser is offline   Reply With Quote
Old 02-08-2010, 05:47 AM   #7
Customer
 
Join Date: Sep 2008
Posts: 51
Rep Power: 9
ronin is on a distinguished road
Default

Quote:
Originally Posted by Yasser
will that work with v 4.1.2 ??


i have added the codes.. but didnt work?

Have you close tags?

{if $SCRIPT_NAME == "/usercheckout.php"}
YOUR CODE HERE
{/if}
ronin is offline   Reply With Quote
Old 02-08-2010, 05:47 AM   #8
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 2,615
Rep Power: 64
seymourjames is a jewel in the rough
Default

This is basic SMARTY - logical operators - come on guys do the search in the smarty manual. I think you mean OR and not AND as well. However, I would use categoryID (use the DEBUG facility to see which variable are available - see 68C documentation on the debug facility).

{if $categoryname == 'CATEGORY NAME 1' || $categoryname == 'CATEGORY NAME 2' || $categoryname == 'CATEGORY NAME 2'}
NO ADS HERE
{/if}

Yes it should work in 4.12 as it did in 4.09. THere are a few threads all about testing for specific pages in the forum for SEO purposes (i.e. assigning page titles and meta descriptions).
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68 Classifieds
seymourjames is offline   Reply With Quote
Old 02-08-2010, 05:58 AM   #9
Customer
 
Yasser's Avatar
 
Join Date: Mar 2009
Posts: 36
Rep Power: 6
Yasser is on a distinguished road
Default

Quote:
Originally Posted by ronin
Have you close tags?

{if $SCRIPT_NAME == "/usercheckout.php"}
YOUR CODE HERE
{/if}
Yes.. thats what i did.

{if $SCRIPT_NAME == "/usercheckout.php"}
{php} some php code{/php}
{else}
{php} some php code{/php}
{/if}


the smarty tags is not doing the job,, its like never been there, the php codes are fine and giving the right output.

thanks
__________________
v4.1.2 Developer -- default Template.
-----------------------------------------------
Yasser is offline   Reply With Quote
Old 02-08-2010, 06:24 AM   #10
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 2,615
Rep Power: 64
seymourjames is a jewel in the rough
Default

And Yasser, does it work if you just put some text in rather than php between the tags? Is the path to usercheckout.php correct?

{if $SCRIPT_NAME == "/usercheckout.php"}
HELLO
{else}
GOODBYE
{/if}
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68 Classifieds
seymourjames is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change a smarty variable damiun Customizations 1 11-23-2009 09:16 AM
smarty debug - getting variables seymourjames Modules / Plugins / Modifications 10 07-07-2008 07:06 PM


All times are GMT -4. The time now is 02:56 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0