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

XF 1.4 auto populate editor by forum

Discussion in 'XenForo Questions and Support' started by dethfire, Sep 20, 2014.

  1. dethfire

    dethfire Well-Known Member

    I'm trying to add a message to the create thread editor textarea depending on the forum, but this isn't working

    <xen:if is="in_array({$thread.node_id}, array(154,154,155,156,157,158))">

    test

    </xen:if>

    If I take the conditional out, test shows. Maybe this conditional doesn't work in create thread?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Try $forum.node_id.
     
  3. dethfire

    dethfire Well-Known Member

    hmmm still doesn't work, strange

    I tried just this too and doesn't work
    <xen:if is="{$forum.node_id} == 153">
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    It works for me.

    Where exactly are you trying to add the text?
     
  5. dethfire

    dethfire Well-Known Member

    <xen:hook name="editor" params="{xen:array 'editorId={$editorId}'}">
    <div>
    <xen:if is="{$showWysiwyg}">
    <textarea name="{$formCtrlNameHtml}" id="{$editorId}_html" class="textCtrl MessageEditor BbCodeWysiwygEditor {$editorOptions.extraClass}" style="display:none; {xen:if $height, 'height: {$height};'}" data-css-url="css.php?style={xen:urlencode $visitorStyle.style_id}&amp;css=editor_contents&amp;d={xen:urlencode $visitorStyle.last_modified_date}" data-dialog-url="index.php?editor/dialog&style={$visitorStyle.style_id}" {xen:if $editorOptions.autoSaveUrl, 'data-auto-save-url="{$editorOptions.autoSaveUrl}"'} {xen:if $editorOptions.json, 'data-options="{xen:escape {xen:helper json, $editorOptions.json}}"'}>{$messageHtml}

    <xen:if is="{$forum.node_id} == 153">

    test

    </xen:if>
    </textarea>
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    Edit the thread_create template.
     
  7. dethfire

    dethfire Well-Known Member

    There is no textarea in thread_create though
     
  8. cclaerhout

    cclaerhout Well-Known Member

    1. Use the editor_setup listener
    2. Use the view to get its parameters:
      PHP:
        $viewParams $view->getParams();
         
      $nodeId = (isset($viewParams['forum'], $viewParams['forum']['node_id'])) ? $viewParams['forum']['node_id'] : null;
         
      $templateName $view->getTemplateName();

    3. And try something like this:
      PHP:
        if($templateName == 'thread_create' && $nodeId)
         {
           switch(
      $nodeId)
           {
             case 
      '1':
               if(
      $showWysiwyg)
               {
                 
      $message '<b>my message</b>';
               }
               else
               {
                 
      $message '[B]my message[/B]';   
               }
               break;
             case 
      '2':
               if(
      $showWysiwyg)
               {
                 
      $message '<b>my message 2</b>'
               
      }
               else
               {
                 
      $message '[B]my message 2[/B]';   
               }
               break;
           }
         }


    P.S: I haven't tried.
     
  9. Brogan

    Brogan XenForo Moderator Staff Member

    It wasn't clear you actually wanted the text in the editor window.

    The node id isn't available in the editor template so you can't do that.
     

Share This Page