Yeah, but how do I get the value of the option? I don't see any methods to interact with XenForo's options.You'd set a js variable with the value of the option
Oh thanks, but are you sure '{$xenOptions}' is valid in this case? I tried it and it returns NaN. Not sure if it's valid to reference like thatvar myVar = '{$xenOptions.option_id}';
then reference it using 'myVar'
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var
Looked already, not applicable I think, it's also kinda useless.
He means to place that in a XenForo template (like page_container_js_head) where $xenOptions can be parsed, and then access 'myVar' from your JavaScript file.Oh thanks, but are you sure '{$xenOptions}' is valid in this case? I tried it and it returns NaN. Not sure if it's valid to reference like that
$.extend(XenForo, {
randomExample: {$xenOptions.optionId}
});
XenForo.randomExample
If you try to understand the code, especially the one in the template, it should become kinda useful (for what you are trying to achieve).Looked already, not applicable I think, it's also kinda useless.
template modification on PAGE_CONTAINER:
Code:$.extend(XenForo, { randomExample: {$xenOptions.optionId} });
Then in your javascript callSomething like this could work?Code:XenForo.randomExample
Which of the above methods is better? Both make a "variable" accessible for use, is there a 'better' method? In terms of efficiency or good practice?var myVar = '{$xenOptions.option_id}';
then reference it using 'myVar'
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var
<button class="Button" data-any-name-you-like="any value you like">Button</button>
<script>
var $button = $('button.Button');
alert($button.data('any-name-you-like')); // creates an alert with the text "any value you like"
</script>
Is there any way to still make it decently call the parent function without the error being thrown? Any way to suppress DW errors for a short time?
class AddOn_DataWriter_Thing extends XFCP_AddOn_DataWriter_Thing
{
public function __construct($errorHandler = self::ERROR_EXCEPTION, array $inject = null)
{
parent::__construct(self::ERROR_SILENT, $inject);
}
}
You could try wrapping it in a try and use catch then check the error message, but that probably isn't the best idea. Only thing I could really think of though
Jake
I tried this:Untested but something like:
PHP:class AddOn_DataWriter_Thing extends XFCP_AddOn_DataWriter_Thing { public function __construct($errorHandler = self::ERROR_EXCEPTION, array $inject = null) { parent::__construct(self::ERROR_SILENT, $inject); } }
That'd make it so that when the parent datawriter is initiated, there's no error handler. Should be careful with that though. A try/catch method like Jake said might be a better route.[/php]
try {
parent::_messagePreSave();
} catch (XenForo_Exception$e) {
unset($this->_errors['message']);
}
However, this works:
PHP:try { parent::_messagePreSave(); unset($this->_errors['message']); } catch (XenForo_Exception $e) { unset($this->_errors[0]); }
Yeah, of course, I'm just seeing what works right now.You may want to verify exactly what error you're unsetting instead of just blindly removing an error
We use essential cookies to make this site work, and optional cookies to enhance your experience.