Jaxel
Well-known member
My god I love XenForo... adding the editor template to your mod couldn't possibly be any easier.
In your action function there should be a similar code to whats below. It wont be the same, since everyone's mod file names and naming structure are different.
As you should know by now, 'MyAddon_ViewPublic_Edit' is the unique ViewPublic class for your page, and 'MyAddon_Edit' is the name of the template the responseView will load up when processing your function. Somewhere in your 'MyAddon_Edit' template should be the following code. Wherever you put it, thats where your editor will be:
The the last thing we must do is create the hook which will add the $editorTemplate to your parameters. Its simple, create a class in '/library/MyAddon/ViewPublic/Edit.php' with the following code.
If you would like there to be a default message (such as if you are editing a page), you simply need to rename 'defaultMessage' to an existing parameter within your page. For instance, to use the $page['page_content'] variable, I changed it as follows:
Remember! I'm an unemployed programmer who enjoys donations!
In your action function there should be a similar code to whats below. It wont be the same, since everyone's mod file names and naming structure are different.
Code:
return $this->responseView('MyAddon_ViewPublic_Edit', 'MyAddon_Edit', $viewParams);
As you should know by now, 'MyAddon_ViewPublic_Edit' is the unique ViewPublic class for your page, and 'MyAddon_Edit' is the name of the template the responseView will load up when processing your function. Somewhere in your 'MyAddon_Edit' template should be the following code. Wherever you put it, thats where your editor will be:
Code:
{xen:raw $editorTemplate}
The the last thing we must do is create the hook which will add the $editorTemplate to your parameters. Its simple, create a class in '/library/MyAddon/ViewPublic/Edit.php' with the following code.
Code:
<?php
class EWRporta_ViewPublic_Edit extends XenForo_ViewPublic_Base
{
public function renderHtml()
{
$this->_params['editorTemplate'] = XenForo_ViewPublic_Helper_Editor::getEditorTemplate(
$this, 'message', $this->_params['defaultMessage']
);
}
}
If you would like there to be a default message (such as if you are editing a page), you simply need to rename 'defaultMessage' to an existing parameter within your page. For instance, to use the $page['page_content'] variable, I changed it as follows:
Code:
$this->_params['page']['page_content'];
Remember! I'm an unemployed programmer who enjoys donations!