Display custom fields from table "Product"

  • Posts: 177
  • Thank you received: 5
11 years 6 months ago #102425

If I use <?php echo $this->row->np; ?>, it shows "Value", not "Title". How to show custom field's Title?
This custom field is used in filter and I need to have the Title displayed in the product description.



Not on Detailed product page. But on Product listing page.

Attachments:
Last edit: 11 years 6 months ago by alikon1.

Please Log in or Create an account to join the conversation.

  • Posts: 177
  • Thank you received: 5
11 years 6 months ago #102442

If I copy this block from Detail product page, it doesn't work on Product listing page :(

<?php
	if(!empty($this->fields)){
		$this->setLayout('show_block_custom_main');
		echo $this->loadTemplate();
	}
	?>

Please Log in or Create an account to join the conversation.

  • Posts: 177
  • Thank you received: 5
11 years 6 months ago #102444

And

<div id="hikashop_product_custom_info_main" class="hikashop_product_custom_info_main">
	<h4><?php echo JText::_('SPECIFICATIONS');?></h4>
	<table width="100%">
	<?php
	$this->fieldsClass->prefix = '';
	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)) {
		?>
			<tr class="hikashop_product_custom_<?php echo $oneExtraField->field_namekey;?>_line">
				<td class="key">
					<span id="hikashop_product_custom_name_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_name">
						<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
					</span>
				</td>
				<td>
					<span id="hikashop_product_custom_value_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_value">
						<?php echo $this->fieldsClass->show($oneExtraField,$value); ?>
					</span>
				</td>
			</tr>
		<?php
		}
	}
	?>
	</table>
</div>
not correct too :(

Please Log in or Create an account to join the conversation.

  • Posts: 177
  • Thank you received: 5
11 years 6 months ago #102450
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 6 months ago #102520

Hi,

A custom field contains the value, not the title. We don't want to store the title in the database, we want the useful data.
The code that you said is not correct, is correct. This is the right way to display the "title" of a custom field (using the "show" function) but it requires that the custom fields are loaded.

Where are you making your tests ?
Which version of HikaShop are you using ?

Regards,

PS: We answer to all posts in the forum, please do not post "empty" message with big crying smiley image. Thanks !


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 177
  • Thank you received: 5
11 years 6 months ago #102790

Resolved by using the same values for Value and Title, but instead spacebar use Alt+255. Because with spacebar in Value filter didn't work. Crooked, but it works)

Please Log in or Create an account to join the conversation.

Time to create page: 0.075 seconds
Powered by Kunena Forum