Hi all,
Is it possible to display a Custom field in a different place to all the other custom fields.
ie RRP at the top of the Product Details page and the rest of the Custom fields ie Size(cart variants at the bottom of the Product details page?
Many thanks once again.
I think the only solution available this time is you should:
- know exactly your customer fields, I mean number of fields, fieldname
- then hack to VM 2 template (product view) to put each field to needed place
Cheers,
MobileMeWs
which field? Is it a plugin?
Hi all,
I want to put a custom product field called "rrp" recomended retail price.... and would like it to appear at the top of my productdetails view page..
Thanks again
Mark
Sent from my Transformer TF101 using Tapatalk
is it in a price field? How are you inputting it?
Hi,
Yes its just a price feld and will only be entered in the product creation /admin
Thanks
Sent from my Transformer TF101 using Tapatalk
WHICH price field is it?
It would just be a custom field as I would like one keep the normal price structure for later use
Sent from my Transformer TF101 using Tapatalk
Quote from: MobileMeWs on November 17, 2011, 08:31:07 AM
I think the only solution available this time is you should:
- know exactly your customer fields, I mean number of fields, fieldname
- then hack to VM 2 template (product view) to put each field to needed place
Cheers,
MobileMeWs
I don't get how to write the code with the custom field number and custom field name in my productdetails template..
For example, in productdetails/tmpl/default.php, there's this line of code:
<span class="product-field-display"><?php echo $field->display ?></span>
I don't know how to substitute the variable by my custom field value, as chosen in the backend..
Thanks
Quote from: spacialek on December 27, 2011, 07:42:24 AM
For example, in productdetails/tmpl/default.php, there's this line of code:
<span class="product-field-display"><?php echo $field->display ?></span>
Just around that code look for
foreach ($this->product->customfields as $field)and change with
foreach ($this->product->customfields as $i=>$field)Than change
<?php echo $field->display ?>with (for example)
<?php echo 'i = [' . $i . '] ' . $field->display ?>It will show you the index of every field you need (or look at Product -> Customfields in back-end).
Than you should check $i and do what you need (by if or case statement). And of course, you can drag a piece of this code into another place of productdetails/tmpl/default.php, make the check there and than show on page what you want.
Thanks a lot for your answer! :)
I did what you mentioned, and as it's the first custom field created, so the value of i gives me 0
I don't know how to write my condition though, I tried the following code, but it doesn't work:
<?php
$custom_title = null ;
//foreach ($this->product->customfields as $field){
foreach ($this->product->customfields as $i=>$field) {
?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
<?php if ($field->custom_title != $custom_title) { ?>
<span class="product-fields-title" ><?php echo JText::_($field->custom_title); ?></span>
<?php if ($field->custom_tip) echo JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png');
} ?>
<?php if($i == 0) { ?>
<span class="product-field-display"><?php $field->display; ?></span>
<?php } ?>
<span class="product-field-desc"><?php echo jText::_($field->custom_field_desc) ?></span>
</div>
<?php
$custom_title = $field->custom_title;
} ?>
I'm sure it's something about the <?php if($i == 0) { ?>
that I have not coded properly
Can you help me with that?
Thanks
ok I found my error!! I forgot the "echo" ::)
So my final code looks like this:
<?php
$custom_title = null ;
//foreach ($this->product->customfields as $field){
foreach ($this->product->customfields as $i=>$field) {
?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
<?php if ($field->custom_title != $custom_title) { ?>
<span class="product-fields-title" ><?php echo JText::_($field->custom_title); ?></span>
<?php if ($field->custom_tip) echo JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png');
} ?>
<?php if($i == 0) { ?>
<span class="product-field-display"> <?php echo $field->display ?></span>
<?php } ?>
<span class="product-field-desc"><?php echo jText::_($field->custom_field_desc) ?></span>
</div>
<?php
$custom_title = $field->custom_title;
} ?>
Thanks thanks thanks for your help!!
You`re welcome! :)
Location of custom fields is in the next release
ok thanks! that's good news, cause it's working great the way it's described in this thread with this code foreach ($this->product->customfields as $i=>$field)
but it's not really convenient, cause the field id changes depending of the order it was added in each product.. so it needs to be really vigilant, otherwise another custom field is displayed instead.