Hello.
Try to add custom type template in SuperBoxSelect select.
But no information about it.
Please help.
The most important step is to set the system setting superboxselect.advanced
to Yes
.
Here are some more details:
No, it didnât help.
version SBS 3.0.7. MODX 2.8.4
the input type have only 2 values: Resources and Users.
How SuperBoxSelect know about my options for render? im need where parametr. as in the resources render-panel, when I select resources.
I try create the folder in core/components/superboxselect/processours/types/templates
And copy the file from users options.class.php, change name of processor, and chane variable:
public $inputOptionType = âtemplatesâ;
After that F5 in manager panel, and in console browser is error, and no exist data input for the TV SuperSelectBox.
What is the schema of your custom database table?
Sheme simple:
modTemplate and FormItForm
It seems that things have changed since I last looked at this extra (and the post I linked above isnât accurate anymore).
I think the proper way to integrate a custom type now is to create a plugin that runs on the event OnSuperboxselectTypeOptions
. But I donât know how that works exactly. The extra SuperBoxFontawesome could be an example but itâs probably too complex for this use case.
Creating another folder in core/components/superboxselect/processors/types
should work though.
Leave the original value public $inputOptionType = 'resources';
. Otherwise the code seems to look for a corresponding xtype (in a file like assets/components/superboxselect/js/types/templates/superboxselect.panel.inputoptions.min.js
).
For the file getlist.class.php
use code like this:
<?php
use TreehillStudio\SuperBoxSelect\Processors\ObjectGetListProcessor;
class SuperboxselectTemplatesGetListProcessor extends ObjectGetListProcessor
{
public $classKey = 'modTemplate';
public $defaultSortField = 'templatename';
public $defaultSortDirection = 'ASC';
public function beforeQuery()
{
$valuesqry = $this->getProperty('valuesqry');
if (!empty($valuesqry)) {
$this->setProperty('limit', 0);
}
return true;
}
public function prepareQueryBeforeCount(xPDOQuery $c)
{
// Get query
$query = $this->getProperty('query');
if (!empty($query)) {
$valuesqry = $this->getProperty('valuesqry');
if (!empty($valuesqry)) {
$c->where([
'id:IN' => explode('||', $query)
]);
} else {
$c->where([
'templatename:LIKE' => '%' . $query . '%'
]);
}
}
$c->select($this->modx->getSelectColumns($this->classKey, $this->classKey, '', ['id', 'templatename']));
// Exclude original value
$originalValue = $this->getProperty('originalValue');
if ($originalValue) {
$originalValue = array_map('trim', explode('||', $originalValue));
$c->where([
'id:NOT IN' => $originalValue
]);
}
if ($this->superboxselect->getOption('debug')) {
$c->prepare();
$this->modx->log(xPDO::LOG_LEVEL_ERROR, $c->toSQL());
}
return $c;
}
public function prepareQueryAfterCount(xPDOQuery $c)
{
$id = $this->getProperty('id');
if (!empty($id)) {
$c->where([
'id:IN' => array_map('intval', explode('||', $id))
]);
}
if ($this->getProperty('sortBy')) {
$c->sortby($this->getProperty('sortBy'), $this->getProperty('sortDir'));
}
$c->sortby($this->getProperty('defaultSortField'), $this->getProperty('defaultSortDirection'));
return $c;
}
public function prepareRow(xPDOObject $object)
{
return [
'id' => $object->get('id'),
'title' => $object->get('templatename')
];
}
}
return 'SuperboxselectTemplatesGetListProcessor';
It helped! Thank you very much!
I knew that it was necessary to designate types somewhere, but I couldnât figure out where. Youâve been very helpful. Thanks!
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting â+ New Topicâ.