Arty
Well-known member
I'm using XenForo color picker in my custom tag.
Issue is getting palette for color picker. It seems weird.
My current code:
That code is inside function in Templater instance.
Here are 2 weird things:
1. When in admin panel, second line that retrieves $style variable returns null. Code works perfectly in public templates, but when styleId is 0, it fails.
2. Whole thing seems too long. Isn't there an easier way to get colorData array? Its inside Templater instance, so its weird that it requires getting style entity and style properties repository.
Issue is getting palette for color picker. It seems weird.
My current code:
Code:
// Code to get color data
$colorData = null;
$style = \XF::em()->find('XF:Style', $this->styleId, null);
if ($style) {
/** @var \XF\Repository\StyleProperty $propertiesRepo */
$propertiesRepo = \XF::repository('XF:StyleProperty');
$colorData = $propertiesRepo->getStyleColorData($style);
}
// Code to add icon picker
$params = [
...
'allowPalette' => $colorData !== null ? 'true' : '',
'includeScripts' => true,
'colorData' => $colorData,
];
$input .= $this->callMacro('public:color_picker_macros', 'color_picker', $params, $this->defaultParams);
Here are 2 weird things:
1. When in admin panel, second line that retrieves $style variable returns null. Code works perfectly in public templates, but when styleId is 0, it fails.
2. Whole thing seems too long. Isn't there an easier way to get colorData array? Its inside Templater instance, so its weird that it requires getting style entity and style properties repository.