1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum is for release discussion only. Discussions that do not relate specifically to the resource release should be discussed in another, more appropriate forum.
    Dismiss Notice
  3. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Hide Poll options when creating a thread

Discussion in 'Template Modifications [Archive]' started by Marcus, Oct 25, 2011.

  1. Marcus

    Marcus Well-Known Member

    From this suggestion: http://xenforo.com/community/threads/user-interface-hide-poll-options-when-creating-a-thread.1362/ Vote for it if you want to implement it to the core. This template modification will add a phrased "Add poll" button between "Add file" and "Preview"

    1.PNG

    which turns on the then deactivated poll options.

    2.PNG

    Like this post if you install this modification.

    New installation advice from Morgain for template thread_create:

    Old installation advice: In template thread_create replace everything after <!-- slot: after_editor --> with

    Code:
    <!-- slot: after_editor -->
     
    <dl class="ctrlUnit submitUnit">
    <dt></dt>
    <dd>
    <input type="submit" value="{xen:phrase create_thread}" accesskey="s" class="button primary" />
    <xen:include template="attachment_upload_button" />
     
    <input type="button" value="{xen:phrase post_poll}" class="button DisableOnSubmit JsOnly" id="button_post_poll") />
     
    <input type="button" value="{xen:phrase preview}..." class="button PreviewButton JsOnly" />
    </dd>
    </dl>
     
    <xen:if is="{$attachmentParams}">
    <dl class="ctrlUnit AttachedFilesUnit">
    <dt><label for="ctrl_uploader">{xen:phrase attached_files}:</label></dt>
    <dd><xen:include template="attachment_editor" /></dd>
    </dl>
     
    <!-- slot: after_attachment -->
    </xen:if>
     
    <xen:if is="{$visitor.user_id}">
    <fieldset>
    <dl class="ctrlUnit">
    <dt>{xen:phrase options}:</dt>
    <dd><ul>
    <li><xen:include template="helper_thread_watch_input" /></li>
    </ul></dd>
    </dl>
     
    <xen:include template="thread_fields_status" />
    </fieldset>
     
    <!-- slot: after_options -->
    </xen:if>
     
    <xen:hook name="thread_create_fields_extra" params="{xen:array 'forum={$forum}'}" />
     
    <div id="post_poll" style="display:none">
     
    <h3 class="textHeading">{xen:phrase post_poll}</h3>
    <dl class="ctrlUnit">
    <dt><label for="ctrl_poll_question">{xen:phrase question}:</label></dt>
    <dd><input type="text" name="poll[question]" class="textCtrl" id="ctrl_poll_question" maxlength="100" /></dd>
    </dl>
    <dl class="ctrlUnit">
    <dt>{xen:phrase possible_responses}:</dt>
    <dd>
    <ul class="PollResponseContainer">
    <li><input type="text" name="poll[responses][]" class="textCtrl" placeholder="{xen:phrase poll_choice}..." maxlength="100" /></li>
    <li><input type="text" name="poll[responses][]" class="textCtrl" placeholder="{xen:phrase poll_choice}..." maxlength="100" /></li>
    </ul>
    <input type="button" value="{xen:phrase add_additional_response}" class="button smallButton FieldAdder" data-source="ul.PollResponseContainer li" data-maxfields="{$xenOptions.pollMaximumResponses}" />
    </dd>
    </dl>
    <!-- slot: after_poll_responses -->
    <dl class="ctrlUnit">
    <dt></dt>
    <dd>
    <ul>
    <li><label for="ctrl_poll_multiple"><input type="checkbox" name="poll[multiple]" value="1" id="ctrl_poll_multiple" /> {xen:phrase allow_selection_of_multiple_responses}</label></li>
    <li><label for="ctrl_poll_public_votes"><input type="checkbox" name="poll[public_votes]" value="1" id="ctrl_poll_public_votes" /> {xen:phrase display_votes_publicly}</label></li>
    <li><label for="ctrl_poll_close"><input type="checkbox" name="poll[close]" value="1" class="Disabler" id="ctrl_poll_close" /> {xen:phrase close_this_poll_after}:</label>
    <ul id="ctrl_poll_close_Disabler">
    <li>
    <input type="text" size="5" name="poll[close_length]" value="7" class="textCtrl autoSize" />
    <select name="poll[close_units]" class="textCtrl autoSize">
    <option value="hours">{xen:phrase hours}</option>
    <option value="days" selected="selected">{xen:phrase days}</option>
    <option value="weeks">{xen:phrase weeks}</option>
    <option value="months">{xen:phrase months}</option>
    </select>
    </li>
    </ul>
    </li>
    </ul>
    </dd>
    </dl>
     
    </xen:hook>
     
    <dl class="ctrlUnit submitUnit">
    <dt></dt>
    <dd>
    <input type="submit" value="{xen:phrase create_thread}" class="button primary" />
    <input type="button" value="{xen:phrase preview}..." class="button PreviewButton JsOnly" />
    </dd>
    </dl>
    </div>
    <script>$('#button_post_poll').click(function() {
      $('#post_poll').slideToggle();
    });</script>
     
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    </form>
     
    <xen:comment><xen:include template="editor" /></xen:comment>
     
    Amor, rafass, Mian Shahid and 8 others like this.
  2. Fuhrmann

    Fuhrmann Well-Known Member

    You have a screenshot?
     
  3. Marcus

    Marcus Well-Known Member

    I have added screenshots to the first post of this template modification thread.​
     
  4. Fuhrmann

    Fuhrmann Well-Known Member

    Thank you Marcus! Very nice!
     
    Marcus likes this.
  5. Marcus

    Marcus Well-Known Member

    Click on Like once you install it :) ( I see you did that :))
     
    Fuhrmann likes this.
  6. Marcus

    Marcus Well-Known Member

    Suggestions if someone wants to improve this modification:
    - auto-scroll to the poll section when activate it
    - auto-scroll back to window top when you deactivate the poll section
     
  7. Edrondol

    Edrondol Well-Known Member

    Like, like, like, love!!
     
  8. iXanon

    iXanon Active Member

    I know it's rare, but what happens in the event of a user browsing with no javascript enabled?
     
  9. Marcus

    Marcus Well-Known Member

    Then the user does not see any "create poll" link at all.
     
  10. kkm323

    kkm323 Well-Known Member

    amazing idea to shorten the page and keeping it simple. Is it possible to make it appear before the thread's subscribe option (y)
     
    Marcus likes this.
  11. Marcus

    Marcus Well-Known Member

    You can change the script to hide the poll area with javascript. If the user does not have javascript, the poll area is not hidden.
     
  12. Marcus

    Marcus Well-Known Member

    You just move the hidden poll-div above the threads subscribe options.
     
  13. Brendon Meynell

    Brendon Meynell Active Member

    Thanks for this it's exactly what I was looking for
     
  14. zaiger

    zaiger Active Member

    Maybe I am missing something but I don't seem to have the text <!-- slot: after_editor --> in my thread_create template.

    When I try to replace the content after <dl class="ctrlUnit submitUnit"> it gives me a syntax error.

    The template is unmodified. Here are the contents, could it be an addon I have installed changed it? The template is still blue in the templates list suggesting that it hasn't been touched though. Any help would be appreciated, thanks in advance.

    EDIT: I am using XF 1.0.4 if that helps.

    Code:
    <xen:title>{xen:phrase create_thread}</xen:title>
     
    <xen:if is="{$forum.description} AND @threadListDescriptions">
        <xen:description class="baseHtml">{xen:raw $forum.description}</xen:description>
    </xen:if>
     
    <xen:navigation>
        <xen:breadcrumb source="$nodeBreadCrumbs" />
    </xen:navigation>
     
    <xen:container var="$head.robots">
        <meta name="robots" content="noindex" /></xen:container>
     
    <form action="{xen:link 'forums/add-thread', $forum}" method="post"
        class="xenForm Preview AutoValidator"
        data-previewUrl="{xen:link 'forums/create-thread/preview', $forum}"
        data-redirect="on"
    >
     
        <xen:if is="{$visitor.user_id} == 0">
            <dl class="ctrlUnit">
                <dt><label for="ctrl_guestUsername">{xen:phrase name}:</label></dt>
                <dd><input type="text" name="_guestUsername" value="{$visitor.username}" class="textCtrl" /></dd>
            </dl>
        </xen:if>
     
        <xen:include template="helper_captcha_unit" />
     
        <fieldset>
            <dl class="ctrlUnit">
                <dt><label for="ctrl_title">{xen:phrase title}:</label></dt>
                <dd><input type="text" name="title" class="textCtrl" data-liveTitleTemplate="{xen:phrase create_thread}: <em>%s</em>" id="ctrl_title" maxlength="100" autofocus="true" /></dd>
            </dl>
     
            <xen:hook name="thread_create_fields_main" params="{xen:array 'forum={$forum}'}" />
     
            <dl class="ctrlUnit fullWidth">
                <dt></dt>
                <dd>{xen:raw $editorTemplate}</dd>
            </dl>
        </fieldset>
     
        <dl class="ctrlUnit submitUnit">
            <dt></dt>
            <dd>
                <input type="submit" value="{xen:phrase create_thread}" accesskey="s" class="button primary" />
                <xen:include template="attachment_upload_button" />
                <input type="button" value="{xen:phrase preview}..." class="button PreviewButton JsOnly" />
            </dd>
        </dl>
     
        <xen:if is="{$attachmentParams}">
            <dl class="ctrlUnit AttachedFilesUnit">
                <dt><label for="ctrl_uploader">{xen:phrase attached_files}:</label></dt>
                <dd><xen:include template="attachment_editor" /></dd>
            </dl>
        </xen:if>
     
        <xen:if is="{$visitor.user_id}">
            <fieldset>
                <dl class="ctrlUnit">
                    <dt>{xen:phrase options}:</dt>
                    <dd><ul>
                        <li><xen:include template="helper_thread_watch_input" /></li>
                    </ul></dd>
                </dl>
     
                <xen:include template="thread_fields_status" />
            </fieldset>
        </xen:if>
     
        <xen:hook name="thread_create_fields_extra" params="{xen:array 'forum={$forum}'}" />
     
        <h3 class="textHeading">{xen:phrase post_poll}</h3>
        <dl class="ctrlUnit">
            <dt><label for="ctrl_poll_question">{xen:phrase question}:</label></dt>
            <dd><input type="text" name="poll[question]" class="textCtrl" id="ctrl_poll_question" maxlength="100" /></dd>
        </dl>
        <dl class="ctrlUnit">
            <dt>{xen:phrase possible_responses}:</dt>
            <dd>
                <ul class="PollResponseContainer">
                    <li><input type="text" name="poll[responses][]" class="textCtrl" placeholder="{xen:phrase poll_choice}..." maxlength="100" /></li>
                    <li><input type="text" name="poll[responses][]" class="textCtrl" placeholder="{xen:phrase poll_choice}..." maxlength="100" /></li>
                </ul>
                <input type="button" value="{xen:phrase add_additional_response}" class="button smallButton FieldAdder" data-source="ul.PollResponseContainer li" data-maxfields="{$xenOptions.pollMaximumResponses}" />
            </dd>
        </dl>
        <dl class="ctrlUnit">
            <dt></dt>
            <dd>
                <ul>
                    <li><label for="ctrl_poll_multiple"><input type="checkbox" name="poll[multiple]" value="1" id="ctrl_poll_multiple" /> {xen:phrase allow_selection_of_multiple_responses}</label></li>
                    <li><label for="ctrl_poll_public_votes"><input type="checkbox" name="poll[public_votes]" value="1" id="ctrl_poll_public_votes" /> {xen:phrase display_votes_publicly}</label></li>
                    <li><label for="ctrl_poll_close"><input type="checkbox" name="poll[close]" value="1" class="Disabler" id="ctrl_poll_close" /> {xen:phrase close_this_poll_after}:</label>
                        <ul id="ctrl_poll_close_Disabler">
                            <li>
                                <input type="text" size="5" name="poll[close_length]" value="7" class="textCtrl autoSize" />
                                <select name="poll[close_units]" class="textCtrl autoSize">
                                    <option value="hours">{xen:phrase hours}</option>
                                    <option value="days" selected="selected">{xen:phrase days}</option>
                                    <option value="weeks">{xen:phrase weeks}</option>
                                    <option value="months">{xen:phrase months}</option>
                                </select>
                            </li>
                        </ul>
                    </li>
                </ul>
            </dd>
        </dl>
     
        <dl class="ctrlUnit submitUnit">
            <dt></dt>
            <dd>
                <input type="submit" value="{xen:phrase create_thread}" class="button primary" />
                <input type="button" value="{xen:phrase preview}..." class="button PreviewButton JsOnly" />
            </dd>
        </dl>
     
        <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    </form>
     
    <xen:comment><xen:include template="editor" /></xen:comment>
     
  15. Marcus

    Marcus Well-Known Member

    This modification works like this:

    1. hide the poll with this statement:


    2. add the "Post Poll" button with this statement:

    3. Activate the button so it hides and shows the hidden poll area with this statement:

     
    zaiger likes this.
  16. zaiger

    zaiger Active Member

    Perfect. Thanks a lot.
     
  17. Morgain

    Morgain Well-Known Member

    OK I too don't have the line you gave as a landmark.
    <!-- slot: after_editor -->
    I think this is your own comment to start the code insertion.

    I also need to know exactly what to insert where because I have a sidebar added to the page at the bottom.
    I'm assuming your replacement goes down to
    Code:
    <xen:comment><xen:include template="editor" /></xen:comment>
    which is the last line on the standard page of code.

    Where does the insertion / replacement begin please?

    I tried putting in the 3 lines you gave above, placing after the hook line:
    Code:
     
    <xen:hook name="thread_create_fields_extra" params="{xen:array 'forum={$forum}'}" />
     
    <div id="post_poll" style="display:none">here is the code of the poll</div>
    <input type="button" value="{xen:phrase post_poll}" class="button DisableOnSubmit JsOnly" id="button_post_poll") />
    <script>$('#button_post_poll').click(function() {$('#post_poll').slideToggle();});</script>
    This gives an error - XF refuses to save it.

    Lovely mod if I can get it to work. I actually suggested it and was directed here!
     
  18. Morgain

    Morgain Well-Known Member

    OK I found in the standard XF code in

    Code:
        <dl class="ctrlUnit submitUnit">
    That matches the first line of your code.
    So I replaced all the existing code with yours up to

    Code:
    <xen:comment><xen:include template="editor" /></xen:comment>
    which is the last line of the original code.

    I still get an error with XF refusing to save it. Error message
    The following templates contained errors and were not saved: thread_create: 1) Line 128: Template syntax error.

    Maybe I have the wrong start point for the replacement.
     
  19. Deepmartini

    Deepmartini Well-Known Member

    This should be in the core. Helps simplify things for new users and makes it easier to post without distraction.
     
    Digital Doctor and zaiger like this.
  20. zaiger

    zaiger Active Member

    I was getting the same error too. I ended up just giving up. I haven't tried it will 1.1 yet, might give it a shot tonight.
     

Share This Page