21280 Posts in 5729 Topics by 2600 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1329 Views |
-
If $string contains (.ss template)

26 May 2009 at 9:58pm
Here is the code from my .ss template:
<a href="$QuotationLink.ATT" title="$QuotationAuthor.ATT">$QuotationAuthor.ATT</a>
if $QuotationAuthor contains the text red then I want this:
<a href="$QuotationLink.ATT" title="$QuotationAuthor.ATT" class="red">$QuotationAuthor.ATT</a>
else I want this:<a href="$QuotationLink.ATT" title="$QuotationAuthor.ATT" class="green">$QuotationAuthor.ATT</a>
-
Re: If $string contains (.ss template)

27 May 2009 at 12:01am Last edited: 27 May 2009 12:01am
Hi,
I don't know what you mean? Give me an example for the $QuotationAuthor variable.
Best regards,
Pascal
-
Re: If $string contains (.ss template)

27 May 2009 at 12:22am Last edited: 27 May 2009 12:24am
Are you looking for something like this?
<a href="$QuotationLink.ATT" <% if QuotationAuthor== "red" %>class="red"<% else %>class="green"<% end_if %>>$QuotationAuthor.ATT</a>
Ben
-
Re: If $string contains (.ss template)

27 May 2009 at 12:23am
If $QuotationAuthor is 'John Red'
Then I want my link to be like this:
<a href="#" title="John Red" class="red">John Red</a>If $QuotationAuthor is 'Bob Frank'
Then I want my link to be like this:
<a href="#" title="Bob Frank" class="green">Bob Frank</a> -
Re: If $string contains (.ss template)

27 May 2009 at 12:25am
<% if QuotationAuthor== "red" %> will NOT work because it checks if $QuotationAuthor EQUALS "red".
I want to test if $QuotationAuthor CONTAINS 'red' anywhere in it.
-
Re: If $string contains (.ss template)

27 May 2009 at 12:29am
You can write a function which checks the $QuotationAuthor. If the function detects the "red" then $output = red | else $output="green". You have to write this in the PHP-File and not in ss-Template-File.
Best regards,
Pascal
-
Re: If $string contains (.ss template)

27 May 2009 at 1:11am
Thank you for pointing me in the right direction. This works! I used a custom text parser.
<?php
class checkSelected extends TextParser
{
function parse(){
$str = $this->content;if(strpos($str,'red')!== FALSE)
return ' class="red" ';
else return ' class="green" ';}
}?>
| 1329 Views | ||
|
Page:
1
|
Go to Top |



