Skip Navigation

[Resolved] Suggestion for addon or a way to call popup

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a View that displays posts. I would like to add a button to each result that triggers a popup dialog with more information about each post. Is there a plugin or addon available for displaying popups with Toolset?

Solution: Toolset does not provide a built-in popup or modal dialog component, but gives you the ability to enqueue the Bootstrap library in Toolset > Settings > General.

The Bootstrap library comes with a built-in modal component that can be used to display popups like you have described.

There is no built-in integration for modals like these in the Block Editor, so custom HTML is required. After enabling the Bootstrap 4 library, add custom HTML to trigger and display modal overlays in your Content Templates and Views. You can place this code in a custom HTML block or in a separate Content Template, then embed that template with the Content Template block. Here is the HTML for an example modal, including the post title in the modal header and the post content and a simple custom field in the modal body:

<!-- Movie modal trigger button -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#movieModal-[wpv-post-id]">
  View More
</button>
 
<!-- Movie modal -->
<div class="modal" tabindex="-1" id="movieModal-[wpv-post-id]" aria-labelledby="movieModalLabel-[wpv-post-id]" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- Movie modal header -->
      <div class="modal-header">
        <h5 class="modal-title" id="movieModalLabel-[wpv-post-id]">[wpv-post-title]</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">x</span>
        </button>
      </div>
 
      <!-- Movie modal body -->
      <div class="modal-body">
        <!-- modal body showing the main post content and a simple custom field -->
        [wpv-post-body view_template="None"]<br />
        [types field="my-field-slug"][/types]
      </div>
 
      <!-- Movie modal footer -->
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

If you place this code in a custom HTML block in your View's loop, a modal will be generated for each item in the loop and a button will be displayed to open the corresponding modal. Notice I have used the wpv-post-id shortcode in the modal structure to create dynamic, unique IDs for each modal in the loop of results. Dynamic IDs are necessary to connect the triggers and modals for each item in the results. You can modify this example code to include your Toolset Types custom fields and other content using our shortcode library.

Relevant Documentation:
https://getbootstrap.com/docs/4.6/getting-started/introduction/
https://getbootstrap.com/docs/4.6/components/modal/
https://toolset.com/documentation/customizing-sites-using-php/functions/
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by keyurA 3 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#2080327

Hey there!

We have designed view using toolset, where require to generate popup which displays post information on clicking on that specific button

kindly suggest us any addon that we can use to generate popup, is there any other way using toolset we can generate popup
kindly review the below video for better understanding
hidden link

hidden link

Thank you

#2080701

Hello, there are no built-in popup interfaces in Toolset or Blocks/Views, nor is there an integration with a popup plugin that I'm aware of. Instead, most people create popups like this with custom HTML and a modal JavaScript library. Toolset provides the option to load the Bootstrap library, which can be found in Toolset > Settings > General.
https://getbootstrap.com/docs/4.6/getting-started/introduction/

The Bootstrap library comes with a built-in modal component that can be used to display popups like you have described: https://getbootstrap.com/docs/4.6/components/modal/

After enabling the Bootstrap 4 library, add custom HTML to trigger and display modal overlays in your Content Templates and Views. There is no built-in integration for modals like these in the Block Editor, so custom HTML is required. You can place this code in a custom HTML block or in a separate Content Template, then embed that template with the Content Template block. Here is the HTML for an example modal, including the post title in the modal header and the post content and a simple custom field in the modal body:

<!-- Movie modal trigger button -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#movieModal-[wpv-post-id]">
  View More
</button>

<!-- Movie modal -->
<div class="modal" tabindex="-1" id="movieModal-[wpv-post-id]" aria-labelledby="movieModalLabel-[wpv-post-id]" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- Movie modal header -->
      <div class="modal-header">
        <h5 class="modal-title" id="movieModalLabel-[wpv-post-id]">[wpv-post-title]</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">x</span>
        </button>
      </div>

      <!-- Movie modal body -->
      <div class="modal-body">
        <!-- modal body showing the main post content and a simple custom field -->
        [wpv-post-body view_template="None"]<br />
        [types field="my-field-slug"][/types]
      </div>

      <!-- Movie modal footer -->
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

If you place this code in a custom HTML block in your View's loop, a modal will be generated for each item in the loop and a button will be displayed to open the corresponding modal. Notice I have used the wpv-post-id shortcode in the modal structure to create dynamic, unique IDs for each modal in the loop of results. Dynamic IDs are necessary to connect the triggers and modals for each item in the results. You can modify this example code to include your Toolset Types custom fields and other content using our shortcode library. We have documentation available for various Toolset shortcodes at the links below.

Types fields shortcodes:
https://toolset.com/documentation/customizing-sites-using-php/functions/
Click "More" under each field type to see examples of shortcodes to display your custom fields.

Views shortcodes:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/
You can use Views shortcodes to output information about each post like the post ID, title, permalink, URL, taxonomies, status, date, slug, featured image, and author information. Relevant example code is included for each shortcode.

Let me know if you have questions about implementing Bootstrap modals or using Toolset shortcodes to display more information about each post.

#2082229

My issue is resolved now. Thank you!