1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Disabling the WYSIWYG editor on just 1 forum...

Discussion in 'Styling and Customization Questions' started by nando99, Jan 7, 2013.

  1. nando99

    nando99 Member

    As the title says...

    I thought this would work but it didn't...

    PHP:
    <xen:hook name="editor" params="{xen:array 'editorId={$editorId}'}">
      <
    div>
        <
    xen:if is="{$showWysiwyg}">
          <
    xen:if is="{$forum.node_id} !== 20">
            <
    textarea name="{$formCtrlNameHtml}id="{$editorId}_html" class="textCtrl MessageEditor" style="display:none; {xen:if $height, 'height: {$height};'}">{$messageHtml}</textarea>
            <
    noscript>
            <
    textarea name="{$formCtrlName}id="{$editorId}class="textCtrl MessageEditor" style="{xen:if $height, 'height: {$height};'}">{$message}</textarea>
            </
    noscript>
            <
    xen:else />
            <
    textarea name="{$formCtrlName}id="{$editorId}class="textCtrl MessageEditor" style="{xen:if $height, 'height: {$height};'}">{$message}</textarea>
          </
    xen:if>
          <
    xen:else />
          <
    textarea name="{$formCtrlName}id="{$editorId}class="textCtrl MessageEditor" style="{xen:if $height, 'height: {$height};'}">{$message}</textarea>
        </
    xen:if>
        <
    input type="hidden" name="_xfRelativeResolver" value="{$requestPaths.fullUri}/>
        <
    xen:if is="{$showWysiwyg}">
          <
    xen:include template="editor_js_setup" />
        </
    xen:if>
      </
    div>
    </
    xen:hook>
    <
    xen:edithint template="editor_contents.css" />
    <
    xen:edithint template="editor_ui.css" />
    <
    xen:edithint template="form.css" />
    Anyone mind pointing me in the right direction? thanks in advance...
     
  2. cclaerhout

    cclaerhout Well-Known Member

    The $forum variable is not available here
    check: {xen:helper dump, $forum}

    Edit: the available variables there are:
    1. 'showWysiwyg'
    2. 'height
    3. 'formCtrlNameHtml'
    4. 'formCtrlName'
    5. 'editorId'
    6. 'message'
    7. 'messageHtml'
    8. 'smilies'
    9. 'editorOptions'
    Which means you can't do here what you want.
     
    nando99 and Chris D like this.
  3. nando99

    nando99 Member

    ... damn! thanks
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    As far as the editor template is concerned, it has absolutely no idea what forum it is being called in. The editor template doesn't understand the parameter "{$forum}".

    You can always test things by placing this in the template:

    {xen:helper dump, $forum}

    When I enter that, the editor template now displays "NULL" instead of any forum details.

    It also doesn't understand the "$node" parameter.

    This can be achieved either with a custom add-on or a code edit. A custom add-on would be much better.

    But here's the code edit. Editing library/XenForo/ViewPublic/Thread/View.php:

    Add the code in red

    Code:
    class XenForo_ViewPublic_Thread_View extends XenForo_ViewPublic_Base
    {
    	public function renderHtml()
    	{
    		$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
    		$bbCodeOptions = array(
    			'states' => array(
    				'viewAttachments' => $this->_params['canViewAttachments']
    			)
    		);
    		XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['posts'], $bbCodeParser, $bbCodeOptions);
    
    		if (!empty($this->_params['canQuickReply']))
    		{
    			$editorOptions = array();
    			if ($this->_params['forum']['node_id'] == 2)
    			{
    				$editorOptions['disable'] = true;
    			}
    			$this->_params['qrEditor'] = XenForo_ViewPublic_Helper_Editor::getQuickReplyEditor($this, 'message', '', $editorOptions);
    		}
    	}
    }
     
    nando99 likes this.
  5. nando99

    nando99 Member

    and making that change to view.php would make it understand $forum.node_id?
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    No, sorry.

    You would only need the View.php code edit above. You wouldn't need to edit the editor template at all.

    See, this part is what disables the editor in forum ID 2:

    Code:
    		if ($this->_params['forum']['node_id'] == 2)
    			{
    				$editorOptions['disable'] = true;
    			}
    This is the Thread View so the forum parameter is there. So we can say if it is node_id 2, then disable the editor.
     
  7. cclaerhout

    cclaerhout Well-Known Member

    The problem with the editor template is that it's not included with the traditional xen tag include. So you can not map a new variable here without modifying php... but I think you will have to modify a lot of files:
    • ViewPublic/Thread/Create.php
    • ViewPublic/Thread/Reply.php
    • ViewPublic/Post/Edit.php
    • ViewPublic/Post/EditInline.php
     
  8. nando99

    nando99 Member

    ah I see, should have looked at your code more closely, thanks!
     
  9. nando99

    nando99 Member


    yeah, it does seem like a lot of work... thanks for the help!
     
  10. cclaerhout

    cclaerhout Well-Known Member

    Mmm... there is another solution, but it's ugly. Use the $requestPaths variable to perform a regex search.
     
  11. nando99

    nando99 Member

    I'm going to try Chris's way and see how it goes... ;)
     
  12. Chris D

    Chris D XenForo Developer Staff Member

    Yes, C├ędric makes a good point.

    That will only remove the quick reply editor from the thread itself. Removing it from the edit pages, create thread pages, reply thread pages actually requires more code edits in different files.

    Are you sure you want to do this? :p
     
  13. nando99

    nando99 Member

    I just want to remove the WYSIWYG editor (and leave the basic editor) on a specific forum :confused:
     
  14. Chris D

    Chris D XenForo Developer Staff Member

    I know what you want to do.

    But the WYSIWYG editor shows up in several places.

    It shows up in the thread, it shows up when you create a thread, it shows up when you click on "More Options" and it shows up when you edit a post in an overlay, or click through to the main edit screen.

    My code edit will only stop it from appearing in the quick reply box at the bottom of the thread.
     
  15. nando99

    nando99 Member

    Ah ok... more information, yes... good...

    I actually (which I should have said earlier) only want this change to take pace when creating a new thread on specific forum.

    So I would have to do something like the change you did in view.php on create.php....
     
  16. Chris D

    Chris D XenForo Developer Staff Member

    Yeah very similar.

    library/XenForo/ViewPublic/Thread/Create.php

    PHP:
    <?php

    class XenForo_ViewPublic_Thread_Create extends XenForo_ViewPublic_Base
    {
        public function 
    renderHtml()
        {
            if (!empty(
    $this->_params['captcha']))
            {
                
    $this->_params['captcha'] = $this->_params['captcha']->render($this);
            }
            
            
    $editorOptions = array();
            if (
    $this->_params['forum']['node_id'] == 2)
            {
                
    $editorOptions['disable'] = true;
            }        

            
    $this->_params['editorTemplate'] = XenForo_ViewPublic_Helper_Editor::getEditorTemplate($this'message'''$editorOptions);
        }
    }
     
    nando99 likes this.
  17. nando99

    nando99 Member

    Awesome, thanks. I'll give it a try in a few.
     

Share This Page