Hi,
and thanks for your desire to help.
Here is what I did already :
1.) Created a View for a list of custom content type nodes - or to make it more obvious - I have a custom content type lets call it Product (for simplicity)
The View is used to show a list of all products (of content type Product) in a short version (like catalogue). On my View I only show a title, linked to node, an image, 3 more simple text fields and the most important 2 - Price field and Promo Price field (where the problem is)
2.) What I want to do - simply to have a custom template for the Price field - and to check (php) IF the Promo Price field for this Product is empy/does not exist
IF the Promo Price field is empty - then simply output the Price field normally
IF the Promo Price field IS NOT empty - then print a simple <span> so the Price field to display as striked-out
3.) I created a template for the Price field, named views-view-field--field-price-value.tpl.php and the Views module recognizes it and uses it when I rescan the template files.
4.) I can't get it working
The only code, that is somehow working is this one :
<?php if ($fields['promoprice_1']->content !== ""): ?>
<?php print '<span style="text-decoration: line-through">'?>
<?php print $output; ?>
<?php print '</span>' ?>
<?php endif; ?>
<?php if ($fields['promoprice_1']->content == ""): ?>
<?php print $output; ?>
<?php endif; ?>
But it doesn't work correctly, because it acts as if I'm asking are ALL of the Promo Price fields empty? And if there is even one, which is not empty - it strikes-out all Price field texts on all rows for all Products.
I've tried uncountable variations of
<?php if (empty($fields['promoprice_1'])) {
print $output;
}
else {
print t('<span style="text-decoration: line-through">');
print $fields['promoprice_1'];
print t('</span>');
} ?>
and so on and so on...
Nothing seems to work, because it looks that I'm not calling the fields the right way I should.
That's why I need help, I hope somebody more familiar with the Views and it's way to address fields will be able to help.
By the way I'm using Table based output, I'm not sure if this is relevant to the solution.
Comments
Comment #1
ramones79 commentedI'm surprised no one answered for more than 3 days.
If, at least, somebody can point me to an URL with Views templating well documented? As the official documentation is very very silent about that. Such a powerful module deserves a better documentation.
Comment #2
merlinofchaos commentedThere are currently 1,231 open issues in this queue. Think about what that means for a moment.
You paid exactly 0 dollars, euros or any other currency for this software. Think about what THAT means for a moment.
Please do not get self-righteous about how much support you get. This software comes with NO implied promise of support. Not in 1 day, not in 3 days, not in 12 days, and not in 12 months. I apologize if this comes off as harsh or mean, but if you want a response, this kind of attitude is going to ensure you do not get one.
In opensource, comments such as this are greeted with "Then contribute some."
Now, let's look for a moment at the documentation that's in the template you're using:
I don't happen to see a $fields variable available. You're trying to use data that isn't there, and then bitching that the documentation sucks when it isn't present. I think the problem here is that you can't read the documentation that exists.
Comment #3
ramones79 commentedYou're right about all of that. Sorry if I pissed you off - not my intention at all.
But I never said, that "documentation sucks", please note that. And yes - I am willing to contribute, if I can. My expertise level about Views or custom PHP/MySQL development is not high at all, but if I can be of some use to the project I will gladly contribute.
Once again please accept my appologize.