Hi world ;)
I try to write a small custom plugin modul that shoul show a dropdown-box.
I already managed it to write the xml-document with a field to insert <option value=" ">" but in the php file i don't manage it to write a select box who STORES the datas in the virtuemart_product_customfields - custom param
I can make it work in a "'.VmHTML::row('input',......
but not in the '.VmHTML::select('select'.....
If someone can help me it would be very glad
thx
<?php
defined('_JEXEC') or die( 'Direct Access to ' . basename( __FILE__ ) . ' is not allowed.' ) ;if (!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
/*
*/
class plgVmCustomLabel extends vmCustomPlugin {
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
$varsToPush = array(
'custom_label'=> array('', 'string'),
'custom_label_name'=> array('', 'string'),
);
$this->setConfigParameterable('custom_params',$varsToPush);
}
function plgVmOnProductEdit($field, $product, &$row,&$retValue) {
if ($field->custom_element != $this->_name) return '';
$this->parseCustomParams($field);
$array = explode(',', $field->custom_label);
$text = ''.Jtext::_('VMCUSTOM_LABLE_VALUE_'.$field->custom_label);
$arr=explode('|',$field->custom_params);
$start=strpos($arr[0],"\"");
$end=strpos($arr[0],"\"", $start+1);
$start2=strpos($arr[1],"\"");
$end2=strpos($arr[1],"\"", $start2+1);
$label=substr($arr[1], $start2+1,$end2-$start2-1);
$array = explode(',', substr($arr[0], $start+1,$end-$start-1));
$myhtl = "<select name='abc'>";
foreach($array as $val) {
$myhtml .= "<option value='".$val."'>$label$val</option>";
}
$endhtml .= "</select>";
$html ='
<fieldset>
<legend>'. JText::_('VMCUSTOM_LABEL_BOX') .'</legend>
<table class="admintable">
'.VmHTML::select('select','VMCUSTOM_LABEL_STRING','custom_param',$myhtml).'
</table>
</fieldset>';
$retValue .= $html;
$row++;
return true ;
}
/**
* We must reimplement this triggers for joomla 1.7
* vmplugin triggers note by Max Milbers
*/
public function plgVmOnStoreInstallPluginTable($psType) {
}
function plgVmDeclarePluginParamsCustom($psType,$name,$id, &$data){
return $this->declarePluginParams($psType, $name, $id, $data);
}
function plgVmSetOnTablePluginParamsCustom($name, $id, &$table){
return $this->setOnTablePluginParams($name, $id, $table);
}
/**
* Custom triggers note by Max Milbers
*/
function plgVmOnDisplayEdit($virtuemart_custom_id,&$customPlugin){
return $this->onDisplayEditBECustom($virtuemart_custom_id,$customPlugin);
}
public function plgVmDisplayInOrderCustom(&$html,$item, $param,$productCustom, $row ,$view='FE'){
$this->plgVmDisplayInOrderCustom($html,$item, $param,$productCustom, $row ,$view);
}
public function plgVmCreateOrderLinesCustom(&$html,$item,$productCustom, $row ){
}
}
u can download mine, and see the code for an example
http://www.kaizenmediaworks.com/virtuemart-2-0-custom-field-dropbox-plugin
I already had a look but wasn't able to do that.
How i sad: i'm able to write a input-field who save the datas in the field, but if i write the select drop-down like this it doesn't store the datas.
The different is between our plugins is my drop-down is in the backend.
If somebody can have a look it woul be very gorgeous.
thx
have you tried the "is a list"
Option in the custom field?
In the "default"
U can separate them with ; and it will make a dropdown list for you
Default This;Makes;List
on my goodness ;)
And i thought i tried every standart custom field. Made myself a lot of work for nothing ;)
great thanks for your reply, your my hero of the month ^^
And here a small other question just to make sure i don't oversight an other function.
Is it possible to create an other checkbox field for the sortby - order by product - tab without a hack?
-> i mean for example sort by "custom-field"
Thanks a lot