Archived

This topic is now archived and is closed to further replies.

  • 0

Resolved How To Pop A Modal From A Hook


Question

Posted · Report post

My understanding is that you can't use shortcodes inside pagelines hooks, but need to use the php that's behind the shortcode instead. I'm trying to place a button in a hook to open a bootstrap modal that displays another website. I can do that from a widget I'm using in a footer:

[pl_modal title="Newsletter Sign-Up" type="btn" colortype="info" label="Newsletter Sign-Up"]

[pageview url="https://somewebsite.com" height="630px" width="100%"]

[/pl_modal]

As you can see I'm using a shortcode inside a shortcode here. But what is the php behind these shortcodes? I can't seem to find them elsewhere.

Thanks

Share this post


Link to post
Share on other sites

6 answers to this question

Posted · Report post

Well, honestly, I wouldn't know what that PHP is either. However, there's one other point you may have missed. You can also use standard HTML inside hooks too. So, if you wanted to use an HREF tag for the link, you could wrap it in a unique div, giving that div padding, margins and a background (the button).

The bigger question is, where do you want the button to appear?

Share this post


Link to post
Share on other sites

Posted · Report post

Hi blatka

One question:

This shortcode "pageview" need PageView plugin that will display another web page inside the current post.

Are you use this plugin?

Share this post


Link to post
Share on other sites

Posted · Report post

Hey Blatka,

You could use a shortcode with a hook, you just also have to give it the instruction to be processed.

For example:

add_action('the_hook_you_want_to_use', 'insert_my_code');
function insert_my_code() {
$shortcode = '[pl_modal title="Newsletter Sign-Up" type="btn" colortype="info" label="Newsletter Sign-Up"]
[pageview url="https://somewebsite.com" height="630px" width="100%"]
[/pl_modal]';
echo do_shortcode($shortcode);
}

You will need to escape any single quotes you have in your shortcode content with a backslash like so ( ' ) if you have any to keep it from breaking your string prematurely. The example code should work as-is as long as you change the hook to a real hook.

You can check out the php for all of the pagelines core shortcodes in pagelines/includes/class.shortcodes.php!

Share this post


Link to post
Share on other sites

Posted · Report post

Hi again

I use your code in a simple post

[pl_modal title="Newsletter Sign-Up" type="btn" colortype="info" label="Newsletter Sign-Up"]

[pageview url="https://apple.com" height="630px" width="100%"]

[/pl_modal]
and this donĀ“t work then I modify for


[pl_modal title="Newsletter Sign-Up" type="btn" colortype="info" label="Newsletter Sign-Up"]

[pageview url="http://apple.com" height="100%" width="100%" border="yes']

[/pl_modal]

This work fine to me

Share this post


Link to post
Share on other sites

Posted · Report post

Thanks Evan . That worked great for me!

Share this post


Link to post
Share on other sites

Posted · Report post

The topic was marked as resolved.

Share this post


Link to post
Share on other sites