Jump to content
paul_t

Modal Dialogue On Page Load

Recommended Posts

paul_t

Is there any way to get a modal dialogue to open on page load (overlay the page)

i.e. the user is required to click something in the modal box (like a warning or a notice) to get the page to load?

Would be great to have this option with the editablity and flexibility that the current modal/button shortcode has.

modal shortcode open

Modal popup content

modal shortcode close

tia

Share this post


Link to post
Share on other sites
catrina

There isn't a way to get the modal to open up automatically, but I believe there should be plugins for this. What kind of information are you trying to add to the modal? A link? A Facebook Like box?


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
paul_t

Before the page opens, the user has the option to...

a ) click a link to go elsewhere

b ) agree to an information box - click the checkbox and open the page

(within the modal popup)

Share this post


Link to post
Share on other sites
paul_t

Went a different route

 

and yes - I know you shouldn't tinker with the actual code

 

but if you amend (slightly) the php class.shortcode.php for Bootstrap Modal Popup from line 1300

 */	
	function pl_modal_shortcode( $atts, $content = null ) {
 
	    extract( shortcode_atts( array(
		    'title'		=> '',
		    'type'		=> '',
		    'colortype' => '',
		    'label' 	=> '',
			'show' 	=> '', //added this
			'hash'		=> rand()
	    ), $atts ) );
 
	    	ob_start();
 
	    		?>
				<script>
	            	jQuery(function(){
						jQuery('#modal_<?php echo $hash; ?>').modal({
							keyboard: true
							, show: <?php echo $show; // amended from JS true or false ?>
						});
					});
				</script><?php

 

you then have a new parameter to use in the shortcode

"show" 

which can be false (default needs a button click to launch)

or true - whereby the modal loads over the page - straight away without the first button click

 

[pl_modal title="Title" type="btn" show='true' colortype="info" label="Click Me!"]

 

all seems fine - but not good to mod the original files so....

 

Question: Probably a Wordpress thing(still a bit new to modifying WP code) - but If I put the whole (modified) function in my child base theme's function.php

and revert the class.shortcodes.php  - it doesnt overwrite the function? confused

Share this post


Link to post
Share on other sites
Simon

You can only define functions once, its a PHP thing.

 

Submit this as a ticket and we'll consider it for inclusion.

Share this post


Link to post
Share on other sites
paul_t

Just copy the whole thing to 

Ideas and Feedback ?

Share this post


Link to post
Share on other sites
paul_t

Did this get implemented? If it did the docs don't mention it?

Share this post


Link to post
Share on other sites
Simon

Yes it did, just add show="true" to the modal shortcode.

Share this post


Link to post
Share on other sites
paul_t

Nice - spread the word in the Documentation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×