[SOLVED] [Send to a friend] conflicting with...

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: [Send to a friend] conflicting with [Plug-in: GoogleMaps] CP

Post by flip-flop »

Not been extensively tested, but it should work:

sendafriend.js (+KH)

Code: Select all

window.addEvent('domready', function() {
									 
	var sendafriend = $('sendafriend');
	if(sendafriend) {
		
		// do not hide send-a-friend form
//		if( $('safsuccess') || $('saferror') ) {
		if( $('safsuccess') || $('saferror') || $('safok') ) {  // +KH:  id safok used in "on success"
			
			sendafriend.setStyle('display', '');                 // +KH
			var sendafriend_status = true;
			
		} else {
		
			var sendafriend_status = false;
			sendafriend.setStyle('display', 'none');
		
		}
		
		$('safbutton').addEvent('click', function(r) {
												  
			if(sendafriend_status == true) {
				
				sendafriend.setStyle('display', 'none');
				sendafriend_status = false;
				
			} else {
				
				sendafriend.setStyle('display', '');
				sendafriend_status = true;
				
			}
		
		});
		
	} 
});
---------
HTML CP: <div id="sendafriend" class="sendafriend" style="display:none">

FORM CP

HTML CP: </div>

Second advantage: The form is not automatically visible if JS is turned off.
---------

If you need a close link in form:

on success (at the end):

Code: Select all

<p id="safok">The recommendation has been sent successfully.</p>
<br />
[PHP]
echo '<a href="index.php?'.$GLOBALS['content']['struct'][$GLOBALS['content']['cat_id']]['acat_alias'].'">Close form</a>';
[/PHP]
and

Form template at the end (presupposes Standard tags assembled):

Code: Select all

<br />
<a href="index.php?{CATEGORY_ALIAS}">Close form</a>
Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Re: [Send to a friend] conflicting with [Plug-in: GoogleMaps] CP

Post by StudioZ »

Oh!!!! :shock: :o :D
Followed your in depth instructions and all is fine now :) 8)
Thanks a bunch Knut !!!

Sincerly,

Yves
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: [SOLVED] [Send to a friend] conflicting with...

Post by flip-flop »

:D
The "Close form"-link has the advantage that the page is reloaded without an anchor and a new form input is immediately possible (we brake the form).
Second, if we use style="display:none" as default, the form is not automatically visible if JS is turned off. :idea:

Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
Post Reply