- Posts: 22
- Thank you received: 0
Add custom-field to product /listing_img_title.php
- kenny.kang
-
Topic Author
- Offline
Less
More
9 years 8 months ago #260317
by kenny.kang
Add custom-field to product /listing_img_title.php was created by kenny.kang
-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.5
I want to add custom-filed display in listing_img_title.php
I have added the following code in php , but can't display $this->element->myfield , always empty
what else code do I need to add!!
foreach ($this->fields as $fieldName => $oneExtraField) {
$value = '';
if(empty($this->element->$fieldName) && !empty($this->element->main->$fieldName))$this->element->$fieldName = $this->element->main->$fieldName;
if(isset($this->element->$fieldName))
$value = trim($this->element->$fieldName);
if(!empty($value)){
$hide_specs = 0;
break;
}
}
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.5
I want to add custom-filed display in listing_img_title.php
I have added the following code in php , but can't display $this->element->myfield , always empty
what else code do I need to add!!
foreach ($this->fields as $fieldName => $oneExtraField) {
$value = '';
if(empty($this->element->$fieldName) && !empty($this->element->main->$fieldName))$this->element->$fieldName = $this->element->main->$fieldName;
if(isset($this->element->$fieldName))
$value = trim($this->element->$fieldName);
if(!empty($value)){
$hide_specs = 0;
break;
}
}
Please Log in or Create an account to join the conversation.
9 years 8 months ago #260323
by nicolas
Replied by nicolas on topic Add custom-field to product /listing_img_title.php
Hi,
The variable $this->element contains the data of the main category of the listing.
So if your listing is displaying the products of the category X, $this->element will contain the data of that category X.
If you want the data of the product being displayed, you'll find it in $this->row
So the code should be $this->row->myfield instead of $this->element->myfield
Such code should do it:
The variable $this->element contains the data of the main category of the listing.
So if your listing is displaying the products of the category X, $this->element will contain the data of that category X.
If you want the data of the product being displayed, you'll find it in $this->row
So the code should be $this->row->myfield instead of $this->element->myfield
Such code should do it:
Code:
<?php echo $this->row->myfield; ?>
Please Log in or Create an account to join the conversation.
Time to create page: 0.152 seconds