- Posts: 109
COMMUNITY FORUM
Backend Extrafields "Default values"
- Franz Heine
-
Topic Author
- Offline
- Premium Member
Less
More
8 years 10 months ago - 8 years 10 months ago #156091
by Franz Heine
Backend Extrafields "Default values" was created by Franz Heine
Hi,
ive updated my K2 to the version 2.7.0
In the former version i had a custom made "checkbox list" for the extrafields. Worked as a backend rating system (see the attached pictures).
Also the link to the site: eco-shops.de/oekostrom.html
Its a mouseover solution (called Eco Index).
Now my problem:
In the "items" view i can see the Eco Index with the labels and values --> see Pic2 --> imgur.com/a/QPziB
If i go in the K2 backend to the "Extra Fields" section, i can see my custom made "K2_Extra_Filed_Multiplecheckbox" --> see Pic1-> imgur.com/a/zPd51
But if i open the "Checkbox list" i cannot see the "Default values" --> see Pic 3 --> imgur.com/a/vRHVM
If i use the general Types like "Multi-select list", i get Default values -- see pic4 --> imgur.com/a/oupcB
Now my question:
Which file is responsible for the default values in the Extra Fields?
Ive backuped the old version und copied the code for the the custom made checklist into the files. I think i forget something.
It would be great, if you have a solution for my problem.
Anyway, thank you and still a great componnet.
ive updated my K2 to the version 2.7.0
In the former version i had a custom made "checkbox list" for the extrafields. Worked as a backend rating system (see the attached pictures).
Also the link to the site: eco-shops.de/oekostrom.html
Its a mouseover solution (called Eco Index).
Now my problem:
In the "items" view i can see the Eco Index with the labels and values --> see Pic2 --> imgur.com/a/QPziB
If i go in the K2 backend to the "Extra Fields" section, i can see my custom made "K2_Extra_Filed_Multiplecheckbox" --> see Pic1-> imgur.com/a/zPd51
But if i open the "Checkbox list" i cannot see the "Default values" --> see Pic 3 --> imgur.com/a/vRHVM
If i use the general Types like "Multi-select list", i get Default values -- see pic4 --> imgur.com/a/oupcB
Now my question:
Which file is responsible for the default values in the Extra Fields?
Ive backuped the old version und copied the code for the the custom made checklist into the files. I think i forget something.
It would be great, if you have a solution for my problem.
Anyway, thank you and still a great componnet.
Last edit: 8 years 10 months ago by Franz Heine. Reason: Solved
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 10 months ago #156114
by Krikor Boghossian
Replied by Krikor Boghossian on topic Backend Extrafields "Default values"
Hello Franz,
The fields are being constructed in the item's model file.
(components/com_k2/models.) The getItemExtraFields() function will help you paste the old functionality back
The fields are being constructed in the item's model file.
(components/com_k2/models.) The getItemExtraFields() function will help you paste the old functionality back
Please Log in or Create an account to join the conversation.
- Franz Heine
-
Topic Author
- Offline
- Premium Member
Less
More
- Posts: 109
8 years 10 months ago #156138
by Franz Heine
Replied by Franz Heine on topic Backend Extrafields "Default values"
Hi Krikor,
thank you for your advice. I could find the code in the components/com_k2/models folder.
Here is the code
Unfortunately no effect in the backend.
Could it be, that ive to change more files in the adminisistrator/components/com_k2 folder?
And another question, if i select the Type "Multiselect-list" ill get in the "Deafult values" fields with theand the
Do you know which file is responsible for this tags?
thank you for your advice. I could find the code in the components/com_k2/models folder.
Here is the code
else if ($rows[$i]->type=='multipleCheckbox'){
// checkboxlist: added whole "else if"
$cnt_nm = count($json->decode($rows[$i]->value));
$total_val = 0;
foreach ($json->decode($rows[$i]->value) as $option)
{
$total_val += $option->name;
}
$v=0;
$tmpArr = array();
$GrpName = $rows[$i]->name;
foreach ($json->decode($rows[$i]->value) as $option){
if (@in_array($option->value,$object->value)) {
$values[$v++] = array("GrpName" => $GrpName, "Label" => $option->label_name, "Value" => $option->name, "Total" => $total_val);
}
}
//$value = @implode(" ",$values);
$value = $values;
}
Unfortunately no effect in the backend.
Could it be, that ive to change more files in the adminisistrator/components/com_k2 folder?
And another question, if i select the Type "Multiselect-list" ill get in the "Deafult values" fields with the
<div id="exFieldsTypesDiv"
<input type="text" name="option_name[]">
Do you know which file is responsible for this tags?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 10 months ago #156148
by Krikor Boghossian
Replied by Krikor Boghossian on topic Backend Extrafields "Default values"
Are the default values being saved in the db?
Please Log in or Create an account to join the conversation.
- Franz Heine
-
Topic Author
- Offline
- Premium Member
Less
More
- Posts: 109
8 years 10 months ago - 8 years 10 months ago #156151
by Franz Heine
Replied by Franz Heine on topic Backend Extrafields "Default values"
Yes,
it should be in the table --> k2_extra_fields.
But thanks for the advice!! When i safe my "multipleCheckbox" the "value" field of the db just shows
But i should have this values in the db field "value"
Hope you have an idea Krikor.
But anyway. Thx a lot for your help. Youre great!
it should be in the table --> k2_extra_fields.
But thanks for the advice!! When i safe my "multipleCheckbox" the "value" field of the db just shows
[]
But i should have this values in the db field "value"
[{"name":"15","label_name":"Detailreiche Produktbilder","value":1,"label_value":1,"target":null,"alias":"checkbox","required":0,"showNull":0},{"name":"10","label_name":"Umweltfreundlicher Versand","value":2,"label_value":2,"target":null,"alias":"checkbox","required":0,"showNull":0},{"name":"15","label_name":"Produktsuche m\u00f6glich","value":3,"label_value":3,"target":null,"alias":"checkbox","required":0,"showNull":0},{"name":"10","label_name":"Shop bietet Angebote \/ Sale","value":4,"label_value":4,"target":null,"alias":"checkbox","required":0,"showNull":0},{"name":"15","label_name":"Produktbewertung m\u00f6glich","value":5,"label_value":5,"target":null,"alias":"checkbox","required":0,"showNull":0},{"name":"15","label_name":"Shop verf\u00fcgt \u00fcber Zertifikate","value":6,"label_value":6,"target":null,"alias":"checkbox","required":0,"showNull":0},{"name":"10","label_name":"F\u00f6rderprogramme f\u00fcr Kunden","value":7,"label_value":7,"target":null,"alias":"checkbox","required":0,"showNull":0},{"name":"10","label_name":"Schneller Seitenaufbau","value":8,"label_value":8,"target":null,"alias":"checkbox","required":0,"showNull":0}]
Hope you have an idea Krikor.
But anyway. Thx a lot for your help. Youre great!
Last edit: 8 years 10 months ago by Franz Heine.
Please Log in or Create an account to join the conversation.
- Franz Heine
-
Topic Author
- Offline
- Premium Member
Less
More
- Posts: 109
8 years 10 months ago - 8 years 10 months ago #156178
by Franz Heine
Replied by Franz Heine on topic Backend Extrafields "Default values"
i could solve the issue:
i had to edit the k2.js file in the folder -->media/k2/assets/js/
But if i save the changes, my "Label name" is empty in the db.
+
Any ideas?
i had to edit the k2.js file in the folder -->media/k2/assets/js/
But if i save the changes, my "Label name" is empty in the db.
[{"name":"15","label_name":null,"value":1,"label_value":1,"target":null,"alias":"checkbox","required":0,"showNull":0}
Any ideas?
Last edit: 8 years 10 months ago by Franz Heine.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 10 months ago #156180
by Krikor Boghossian
Replied by Krikor Boghossian on topic Backend Extrafields "Default values"
This is a shot in the dark but you can try the following files:
/administrator/components/k2/views/extrafield/
/administrator/components/k2/views/item/ (to see if there where any hardcoded parts for the new type)
/administrator/components/k2/models/extrafield.php
The JavaScript file has had some modifications since the last update so be careful :)
/administrator/components/k2/views/extrafield/
/administrator/components/k2/views/item/ (to see if there where any hardcoded parts for the new type)
/administrator/components/k2/models/extrafield.php
The JavaScript file has had some modifications since the last update so be careful :)
Please Log in or Create an account to join the conversation.
- Franz Heine
-
Topic Author
- Offline
- Premium Member
Less
More
- Posts: 109
8 years 10 months ago #156186
by Franz Heine
Replied by Franz Heine on topic Backend Extrafields "Default values"
Thx Krikor,
worked fine. --> administrator/components/k2/models/extrafield.php was the solution.
My "checkbox" works fine in the backend (db included)
For the frontend im using components/com_k2/templates/default/item.php
Ive put my code into this file. unfortunately i cannot display my "backend rating".
See here:
eco-shops.de/bio-lebensmittel/amorebio.html
Did you make big changes at the frontend templates?
And do i have to change something specific to get the db infos? Or is it like before?
worked fine. --> administrator/components/k2/models/extrafield.php was the solution.
My "checkbox" works fine in the backend (db included)
For the frontend im using components/com_k2/templates/default/item.php
Ive put my code into this file. unfortunately i cannot display my "backend rating".
See here:
eco-shops.de/bio-lebensmittel/amorebio.html
Did you make big changes at the frontend templates?
And do i have to change something specific to get the db infos? Or is it like before?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 10 months ago #156192
by Krikor Boghossian
Replied by Krikor Boghossian on topic Backend Extrafields "Default values"
The templates have been changed, but if you where using overrides, you shouldn't notice a difference.
How was this rating calculated? Was it pure CSS, JS or with some PHP code on your template?
How was this rating calculated? Was it pure CSS, JS or with some PHP code on your template?
Please Log in or Create an account to join the conversation.
- Franz Heine
-
Topic Author
- Offline
- Premium Member
Less
More
- Posts: 109
8 years 10 months ago #156212
by Franz Heine
Replied by Franz Heine on topic Backend Extrafields "Default values"
the rating is calculated in the components/com_k2/templates/default/item.php
at the bottom ive
it works fine with -->
but i cannot get the values-->
<!-- # New Rating System Start Here -->
<?php
if($this->item->params->get('itemRating')): ?>
<?php
if (count($this->item->extra_fields) > 0 && is_array($this->item->extra_fields)) {
$dispArr = array();
$m=0;
foreach ($this->item->extra_fields as $key=>$extraField)
{
if ($extraField->name == "Eco")
{
$dispArr[$m]['Name'] = $extraField->name;
$dispArr[$m]['Value'] = $extraField->value;
$m++;
}
}
$tipVal = '';
if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)) {
$tipVal .= '<div id="itemExtraFieldsToolTip" class="itemExtraFieldsToolTip">';
$tipVal .= '<label class="extra-title">'.$this->item->title.'</label>';
$cnt_dispArr = count($dispArr);
$chkVal = 0;
for ($v=0; $v<$cnt_dispArr; $v++)
{
if (is_array($dispArr[$v]['Value']))
{
$cnt_valArr = count($dispArr[$v]['Value']);
$tipVal .= '<div class="ratinglinedesc"><ul style="padding:0; margin:0;">';
//$tipVal .= '<div class="extra-desc-lbl">'.$dispArr[$v]['Value'][0]['GrpName'].'</div>';
$totalChkVal = $dispArr[$v]['Value'][0]['Total'];
for ($m=0; $m<$cnt_valArr; $m++)
{
$strLabel = $dispArr[$v]['Value'][$m]['Label'];
$chkVal += $dispArr[$v]['Value'][$m]['Value'];
$tipVal .= '<li class="extra-desc-txt">'.$strLabel.'</li>';
}
$tipVal .= '</ul></div>';
} else {
$tipVal .= '<div style="margin-bottom:6px;width:100%;float:left;"><div class="extra-desc-lbl">'.$dispArr[$v]['Name'].'</div>';
$tipVal .= '<div class="extra-desc-txt">'.$dispArr[$v]['Value'].'</div></div>';
}
}
$tipVal .= '</div>';
}
}
?>
<!-- Item Rating -->
<div class="itemRatingBlock">
<span><?php echo JText::_('K2_RATE_THIS_ITEM'); ?></span>
<div class="itemRatingForm">
<ul class="itemRatingList">
<li class="itemCurrentRating" id="itemCurrentRating<?php echo $this->item->id; ?>" style="width:<?php echo $this->item->votingPercentage; ?>%;"></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" title="" class="one-star">1</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" title="" class="two-stars">2</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" title="" class="three-stars">3</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" title="" class="four-stars">4</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" title="" class="five-stars">5</a></li>
</ul>
<div id="itemRatingLog<?php echo $this->item->id; ?>" class="itemRatingLog"><?php echo $this->item->numOfvotes; ?></div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<div class="itemRatingBlock" style="width:100%;float:left;">
<span><?php echo JText::_('Eco'); ?></span>
<div style="float:left;" class="ratingK2analysis">
<?php
$PercentSel = ($totalChkVal>0 && $totalChkVal !='')?floor((100*$chkVal)/$totalChkVal):0;
$setAct = floor($PercentSel/20);
$setClass='';
for ($m=0; $m<5; $m++)
{
if ($m < $setAct) {
$setClass = ' active';
} else {
$setClass = '';
}
echo '<div class="rating-bg-div'.$setClass.'"></div>';
}
?>
</div>
</div>
<?php endif; ?>
<!-- # New Rating System End Here -->
at the bottom ive
<script type="text/javascript">
jQuery('document').ready(function(e) {
jQuery('.ratingK2analysis').attr('title', '<?=$tipVal?>');
jQuery(".ratingK2analysis").tipTip();
});
</script>
it works fine with -->
<label class="extra-title">'.$this->item->title.'</label>
but i cannot get the values-->
if (is_array($dispArr[$v]['Value']))
{
$cnt_valArr = count($dispArr[$v]['Value']);
$tipVal .= '<div class="ratinglinedesc"><ul style="padding:0; margin:0;">';
//$tipVal .= '<div class="extra-desc-lbl">'.$dispArr[$v]['Value'][0]['GrpName'].'</div>';
$totalChkVal = $dispArr[$v]['Value'][0]['Total'];
for ($m=0; $m<$cnt_valArr; $m++)
{
$strLabel = $dispArr[$v]['Value'][$m]['Label'];
$chkVal += $dispArr[$v]['Value'][$m]['Value'];
$tipVal .= '<li class="extra-desc-txt">'.$strLabel.'</li>';
}
$tipVal .= '</ul></div>';
}
Please Log in or Create an account to join the conversation.
- Franz Heine
-
Topic Author
- Offline
- Premium Member
Less
More
- Posts: 109
8 years 10 months ago #156280
by Franz Heine
Replied by Franz Heine on topic Backend Extrafields "Default values"
EDIT: Solved the problem
I had a bug in the item.php in the folder--> components/com_k2/models
Thank you for your help Krikor!
I had a bug in the item.php in the folder--> components/com_k2/models
Thank you for your help Krikor!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 10 months ago #156290
by Krikor Boghossian
Replied by Krikor Boghossian on topic Backend Extrafields "Default values"
Nice to hear that you solved the issue :)
Please Log in or Create an account to join the conversation.