Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author ka2

    (@ka2)

    Sorry for my late reply.

    Your requests can be achieved by the following as.

    First, you will create a new post to become as container into inserting shortcode. For example, on this post name will name the “shortcode-insertion”. Also, The content body of this post is nothing.

    Then, you markup the JavaScript to invoke the modal as follows.

    $('.myNewModal').on('click', function(event){
      event.preventDefault();
      $('#myNewModal').find('.modal-body').html('<iframe src="/shortcode-insertion/?table=' + $(this).attr('value') + '" width="100%"></iframe>').end().modal('show');
    });

    Finally, you add a filter to dynamically generate a shortcode from the table name that received in the GET query. You should add to the place where is “functions.php” in your theme.

    function custom_shortcode_insertion( $post_content ){
      if ('shortcode-insertion' === $GLOBALS['post']->post_name) {
        if (array_key_exists('table', $_GET) && !empty($_GET['table'])) {
          $post_content = sprintf('[cdbt-entry table="%s"]', $_GET['table']);
        }
      }
      return $post_content;
    }
    add_filter( 'the_content', 'custom_shortcode_insertion' );

    Please try as above.

    Thread Starter ugirishm

    (@ugirishm)

    Thanks a lot for providing the code. I tried it out and having some issues. But is there a way to do this without creating a new post? The theme I am using will add all the other formating into the post and hence the modal box is having lots of unrequired information. Can you provide me a solution which does not require creating a new post.

    Thanks,
    Girish

    Thread Starter ugirishm

    (@ugirishm)

    Hi,

    I am able to create a blank page with the use of templates. However, looks like the custom short code function is not being called and hence the short code is not getting pasted into the blank page

    Can you please help?

    Thanks,
    Girish

    Plugin Author ka2

    (@ka2)

    Hi there,

    Please try the way that it’ll expand the shortcode in the return value of the function “custom_shortcode_insertion()”. For example, as described below:

    return do_shortcode($post_content);

    Thank you,

    Thread Starter ugirishm

    (@ugirishm)

    Thanks for the response. The entry form is showing up now. However, the format is not working fine now. Can you please let me know if any style sheets need to be added?

    please take a look at the below link for the issue : https://oshparks.org/blank/?table=Training

    Thanks,
    Girish

    Thread Starter ugirishm

    (@ugirishm)

    Thanks. I have fixed this with temporary solution of adding the CDBT stylesheet to the blank page.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Dynamically opening CDBT in modal page’ is closed to new replies.