id fields display element separately?

  • Posts: 37
  • Thank you received: 0
10 years 8 months ago #184514

-- HikaShop version -- : 2.3.4.
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.3.29

As in listing_title.php using id fields display element separately?
The code prints out the entire list fields:

<?php
$this->fieldsClass = hikashop_get('class.field');
$this->fields = $this->fieldsClass->getFields('frontcomp',$this->row,'product','checkout&task=state');
$this->element =& $this->row;
$this->setLayout('show_block_custom_mains');
echo $this->loadTemplate();
?>

I in fields 10 items on the product page listing_title can bring 4 items? Using ID fields?

product / show_block_custom_mains :

<span id="hikashop_product_custom_name_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_name" style="float:left;">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>

<?php echo $this->fieldsClass->show($oneExtraField,$value); ?>
</span>

reklammma.ru/

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 8 months ago #184600

Hi,

I'm sorry but I don't understand your problem.
Could you give a link to a product page where you have your fields, and link to the listing where that product is displayed and the full code of listing_list and show_block_custom_mains that you have on your website ? Please put the code between the [ code ] and [ /code ] tags (without the spaces) in your message so that it displays properly on the forum.

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

  • Posts: 37
  • Thank you received: 0
10 years 8 months ago #185393

product / show_block_custom_main
foreach - displays all fields
how to get 1 item ? id fields, or number, for example 4 fields.

<?php
$this->fieldsClass->prefix = '';
$displayTitle = false;
ob_start();
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) || $value === '0') {$displayTitle = true;?>

<?php echo $this->fieldsClass->getFieldName ($oneExtraField);?> - displays all fields
<?php echo $this->fieldsClass->show($oneExtraField,$value); ?> - displays all fields

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 8 months ago #185669

Hi,

It would be great to follow what I wrote in my previous message.
Because it's still not clear.
If you want only 4 fields you can add the line:
static $count=0;$count++;if($count>4) continue;
after the line:
foreach ($this->fields as $fieldName => $oneExtraField) {

And no, the code :
<?php echo $this->fieldsClass->show($oneExtraField,$value); ?>
doesn't display all the fields. It displays only one field.

Last edit: 10 years 8 months ago by nicolas.
The following user(s) said Thank You: Vorov

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

  • Posts: 37
  • Thank you received: 0
10 years 6 months ago #193822

you can use the function array_shift skip 1 element, starting from the second ?

I have an array 1,2,3,4,5,6,7,8
need 2,3,4,5

foreach ($this->fields as $fieldName => $oneExtraField) {

static $count=0;$count++;if($count>4) continue;
$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) || $value === '0')

{ $displayTitle = true;?>
<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>

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 6 months ago #193961

Then you can use such code instead:
static $count=0;$count++;if($count>5 || $count == 1) continue;

The following user(s) said Thank You: Vorov

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

  • Posts: 37
  • Thank you received: 0
10 years 6 months ago #194508

Everything works fine, thanks!
:woohoo:

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

Time to create page: 0.064 seconds
Powered by Kunena Forum