[support] How to translate a value entered in CCK field into something else on the page

Fred Jones fredthejonester at gmail.com
Tue Apr 8 10:05:40 UTC 2008


Neil: esl-lounge.com wrote:
> I am using the following in my node-blog.tpl.php:
>  
> <div class="blog-image" style="float:<?php print 
> $node->field_image_float[0]['view'] ?>;padding:8px;margin:5px;"><?php 
> print $node->node_images ?></div>
>  
> and giving users the chance to float the image to the left or right. And 
> it's working fine on my English site but now want to give the same tools 
> to my Italian site users. I could just use "left" and "right" and 
> explain in the help text what each of them means, but I would prefer to 
> use the Italian words sinistra/destra and then use some conditional php 
> to transform that into left/right on the template. Is that a complicated 

If I have understood you correctly, then try this:

<?php
$side = 'sinestra' == $node->field_image_float[0]['view'] ? 'right' : 
'left';
?>

and then use this:

style="float:<?php print $side ?>

See here:

http://www.msbware.com/articles/php/unary_binary_and_ternary_operators.html

for more info.

Fred


More information about the support mailing list