- Posts: 37
- Thank you received: 0
id fields display element separately?
11 years 9 months ago #184514
by Vorov
id fields display element separately? was created by Vorov
-- 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/
-- 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.
11 years 9 months ago #184600
by nicolas
Replied by nicolas on topic id fields display element separately?
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.
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.
11 years 8 months ago #185393
by Vorov
Replied by Vorov on topic id fields display element separately?
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
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.
11 years 8 months ago - 11 years 8 months ago #185669
by nicolas
Replied by nicolas on topic id fields display element separately?
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.
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: 11 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.
11 years 6 months ago #193822
by Vorov
Replied by Vorov on topic id fields display element separately?
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>
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.
11 years 6 months ago #193961
by nicolas
Replied by nicolas on topic id fields display element separately?
Then you can use such code instead:
static $count=0;$count++;if($count>5 || $count == 1) continue;
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.
11 years 6 months ago #194508
by Vorov
Replied by Vorov on topic id fields display element separately?
Everything works fine, thanks!
:woohoo:
:woohoo:
Please Log in or Create an account to join the conversation.
Time to create page: 0.245 seconds