- Posts: 431
- Thank you received: 22
Custom field in description if
7 years 3 months ago #307108
by mojweb
Custom field in description if was created by mojweb
-- HikaShop version -- : 4.0.3
-- Joomla version -- : 3.9.6
-- PHP version -- : 7.2
I have customized view product/show_default to show some custom fields like that
I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up.
thank you
-- Joomla version -- : 3.9.6
-- PHP version -- : 7.2
I have customized view product/show_default to show some custom fields like that
Code:
<div class="row-fluid">
<div class="col-sm-2 phot"><?php
$fieldClass = hikashop_get('class.field');
$field = $fieldClass->getField('autorfoto', 'product');
echo $fieldClass->show($field,$this->element->autorfoto);
?>
</div>
<div class="col-sm-10 text"><?php echo $this->element->autortext; ?></div>
</div>
thank you
Please Log in or Create an account to join the conversation.
7 years 3 months ago #307112
by nicolas
Replied by nicolas on topic Custom field in description if
Hi,
You can do like that:
You can do like that:
Code:
if(!empty($this->element->autortext)) {
// your code
}
Please Log in or Create an account to join the conversation.
7 years 3 months ago #307209
by mojweb
Replied by mojweb on topic Custom field in description if
I get error. Something doing it wrong. Can you please add me code to my code.
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
7 years 3 months ago #307220
by Mohamed Thelji
Replied by Mohamed Thelji on topic Custom field in description if
Hello,
You should try it like this :
You should try it like this :
Code:
<div class="row-fluid">
<div class="col-sm-2 phot"><?php
$fieldClass = hikashop_get('class.field');
$field = $fieldClass->getField('autorfoto', 'product');
echo $fieldClass->show($field,$this->element->autorfoto);
?>
</div>
<div class="col-sm-10 text"><?php
if(!empty($this->element->autortext)) {
echo $this->element->autortext;
}
?>
</div>
</div>
Please Log in or Create an account to join the conversation.
7 years 3 months ago #307346
by mojweb
Replied by mojweb on topic Custom field in description if
Sorry for bother.
Now I get in html output
Image is not selected, so it should be empty. And I need to hide divs to if empty field.
Now I get in html output
Code:
<div class="row-fluid">
<div class="col-sm-2 avtorphot"><img class="" src="/poslovno/order/download/field_table-product/field_namekey-YXV0b3Jmb3Rv/name-/thumbnail_x-100/thumbnail_y-100" alt=""> </div>
<div class="col-sm-10 avtortekst"></div>
</div>
Image is not selected, so it should be empty. And I need to hide divs to if empty field.
Please Log in or Create an account to join the conversation.
7 years 3 months ago #307355
by kyratn
Replied by kyratn on topic Custom field in description if
Hi,
Try like this:
Thanks
Try like this:
Code:
<div class="row-fluid">
<?php
$fieldClass = hikashop_get('class.field');
$field = $fieldClass->getField('autorfoto', 'product');
if(!empty($fieldClass->show($field,$this->element->autorfoto)))
{?>
<div class="col-sm-2 phot"><?php echo $fieldClass->show($field,$this->element->autorfoto);?></div>
<?php } if(!empty($this->element->autortext)) {?>
<div class="col-sm-10 text"><?php echo $this->element->autortext;?></div>
<?php }?>
</div>
Thanks
Please Log in or Create an account to join the conversation.
7 years 3 months ago #307347
by nicolas
Replied by nicolas on topic Custom field in description if
Like that then:
Code:
<div class="row-fluid">
<?php
if(!empty($this->element->autorfoto)) {
$fieldClass = hikashop_get('class.field');
$field = $fieldClass->getField('autorfoto', 'product');
echo '<div class="col-sm-2 phot">' . $fieldClass->show($field,$this->element->autorfoto) . '</div>';
}
if(!empty($this->element->autortext)) {
echo '<div class="col-sm-10 text">' . $this->element->autortext . '</div>';
}
?>
</div>
The following user(s) said Thank You: mojweb
Please Log in or Create an account to join the conversation.
7 years 3 months ago #307522
by mojweb
Replied by mojweb on topic Custom field in description if
Nicolas, that is working great. Thank you.
Please Log in or Create an account to join the conversation.
Time to create page: 0.267 seconds