Recent searches
No recent searches
How Can I Add Specific Text in new_request_page.hbs template based on Ticket Form ID?
Answered
Posted Aug 06, 2021
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
17
17 comments
Ifra Saqlain
Hi Lila Kingsley,
Try the given code on new request page:
The given code for script file:
If any confusion let me know :)
Thanks
Team Diziana
0
Lila Kingsley
Awesome, thanks yet again Ifra! :)
I am a bit leery of using JavaScript though...a script we had on the new_request_page.hbs template for YEARS recently broke (despite not being changed!!) which caused tickets to not be created :( .
Do you or anyone know if what I am trying to do is possible with just curlybars?
-Lila
0
Lila Kingsley
Hi Ifra,
Thanks again for all your help. I got the code to work but did get an error at first. Wanted to share the solution here in case there are other JavaScript newbies like me searching this post in the future. Also, would love to know if you think there's a better/different solution.
FYI I updated the original JS snippet: basically I changed the function name and updated it to look for 2 classes/forms (instead of 3)...and added a console.log statement for testing purposes.
When it initially ran I saw the error Uncaught TypeError: Cannot read property 'style' of null at the first document.querySelector line in the browser inspect console. Searching online pointed to the code needing to wrapped in a "document ready handler", such as this one I found in stackoverflow.
Wrapping the code in that fixed it. I now see the text I want on each form, and the console.log is logging as I expect. Here's the code that worked:
1
Ifra Saqlain
Hi Lila Kingsley, I know I'm too late to reply but I tried it with the curlybars but nothing happened throughing error so I used the JavaScript and thanks to share the solution for newbies.
If users are using jQuery so they can do like this:
1). Add the jQuery CDN on document_head.hbs file.
2). Add the script code at the bottom of your script.js file.
3). The title which would be add on new_request_page.hbs
Thanks
Ifra
2
Lila Kingsley
Thanks Ifra! :)
0
Ifra Saqlain
:)
0
Swapnali Padale
HI,
How to add add text dynamically?
0
Ifra Saqlain
Hi Swapnail,
You should see this article where I'm adding DC text via JS.
https://support.zendesk.com/hc/en-us/community/posts/4451902570522-Changing-dynamic-text-elements-in-Gather
If any queries, feel free to ask :)
Thanks
0
Ifra Saqlain
@Swapnali Bhadale, it is possible but How many blocks will you add I mean setting the panel has a limit if you have 6 or, 8 or, 12 you can but if you have a list in every col then you should write code to the hbs file instead of the manifest file.
I can guide you to add settings to the panel but first tell me, how many items are in each column and how many settings exist in your setting panel currently?
0
Swapnali Padale
Thanks Ifra Saqlain.
0
Ifra Saqlain
:)
0
Zach
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
Ifra Saqlain
Hi Zach,
1). Add the jQuery CDN on document_head.hbs file.
2). Add the script code at the bottom of your script.js file.
3). The title which would be added on new_request_page.hbs
If any confusion feel free t0 ask :)
Thanks
0
Zach
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
Ifra Saqlain
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:
Add a <h2> tag like this:
0
Zach
Thank you so much, Ifra Saqlain.
Would it be possible to do something similar with this new_request_tip_text element?
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
Ifra Saqlain
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