最近の検索


最近の検索はありません

How Can I Add Specific Text in new_request_page.hbs template based on Ticket Form ID?

回答済み


投稿日時:2021年8月06日

Hi,

I'm working on adding a new contact form to our help center and routing end users to specific ticket form based on where they clicked the submit a request link (thanks to help from Ifra Saqlain & the community!!). 

Now, I am hoping I can customize text above the request form based on the ticket form id (today we have one from with text above it without special logic). What I want now is:

  • Have Ticket Form A show Text A above the form 
  • Have Ticket Form B to show Text B above the form
  • Have Text C follow both Text A and Text B above the form.

I've tried the code below but it's not working.  Text A appears on both forms, and, it appears UNDER B.  Does anyone know how to do this/what's up with my code?  

{{#each ticket_forms}}
{{#is id 123}}
<p>Text A</p>
{{else}}
<p>Text B</p>
{{/is}}
{{/each}}
<p>Text C</p>
<br>
<div class="new-request-form">
{{request_form}}
</div>

1

19

19件のコメント

      Hi Zach,
       
      Thanks for sharing the additional details!
       
      To have text appear beneath a custom field only when a specific drop-down value is selected, some custom JavaScript would be necessary. While the new_request_tip_text element works well for static tip text, showing or hiding text based on the selected option requires listening for field changes and dynamically adjusting the display.
       
      This approach typically involves adding an event listener to the drop-down and toggling the visibility of the disclaimer text accordingly within your theme’s JavaScript.
       
      Hope this helps clarify how it can be achieved!

      0


      Hi, again, 1263169183150 :)

      I'm curious if you have any suggestions for accomplishing this but instead of under the title of a form, I want the text to appear underneath a custom field, and ONLY when a specific drop-down value for that field is selected..?

      Utilizing a custom field description would suffice but ultimately, I'd like this text to pop out the customer, more like a disclaimer, than a description.

      0


      Zach,  In this case, you don't need to add JS code, you already have a textbox in your setting panel to edit the text.

       

      Go to your settings panel and find the textbox of New Request Tip Text to edit the text.

      0


      Thank you so much, Ifra Saqlain.
      Would it be possible to do something similar with this new_request_tip_text element?

      {{#if settings.show_new_request_tip}}
              <div class="lt-new-request-tip lt-p-4 lt-ps-8 lt-mb-4">
                <i class="fas fa-magic lt-new-request-tip__icon" aria-hidden="true"></i>
                {{settings.new_request_tip_text}}
              </div>
              {{/if}}

       

      This "tip" object was provided in a custom theme. I tried messing around with

      $(“.new-request-tip”).text(‘TEST TEST TEST’) 

      but this didn't seem to work out well. The text itself never populated and the ticket form title was disappearing for some reason.

      0


      That code is only for the one web form when you add form-id into the script code.

      You can change the structure of HTML like the given below.

      script code would be:

      $(document).ready(function(){
        function ticketFormText(){
          $("h2.form-a-text").hide();
         
          if (window.location.href.indexOf("00000000000000") > -1){
            $("h2.form-a-text").show();
          }
        }
        ticketFormText();
      })

       

       

      Add a <h2> tag like this:

       

      0


      Sorry, Ifra Saqlain -- I should have been clearer. I'm not looking for this in the Title but as a blurb beneath it. Here's a screenshot:

      0


      Hi Zach, 

      1). Add the jQuery CDN on document_head.hbs file.

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

       

      2). Add the script code at the bottom of your script.js file.

      $(document).ready(function(){
      function ticketFormText(){
      $("h1.form-a-text > span").hide();

      if (window.location.href.indexOf("Form_ID_A") > -1){
      $("h1.form-a-text > span").show();
      }
      }
      ticketFormText();
      })


      NOte: Form_ID_A here is you form ID where you want to show the title

       

      3). The title which would be added on new_request_page.hbs

      <h1 class="form-a-text">


       <br>  <span>Text A</span>
      </h1>


      Note: I added a class-name to <h1> tag and add title in <span> tag.


       

      If any confusion feel free t0 ask :)

      Thanks

       

       

      0


      Ifra Saqlain - I'm trying to simply add a snippet of text below the title but I only want it on a single form. Any chance you could assist :) ????

      0


      :)

      0


      Thanks Ifra Saqlain.

       

       

      0


      サインインしてコメントを残します。

      お探しのものが見つかりませんか?

      新規投稿