Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Open a Shadowbox upon entering a page - with a smarty IF

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-24-2009, 05:56 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Open a Shadowbox upon entering a page - with a smarty IF

I've blown more than an hour on this... anyone know the trick?

My goal: upon loading a page, use a smarty if to determine if an element should be displayed, then show it, inside a Shadowbox (div/html, iFrame, whatever).

For example, in home.tpl, in the <head>:

Code:
{* SHADOWBOX INCLUDE *} {if $smarty.get.reviewed eq "yes"} {include file="shadowbox_include-review-confirm.tpl" } {else} {include file="shadowbox_include.tpl" } {/if} {* END-SHADOWBOX INCLUDE *}

Then the include would contain the javascript, as detailed from the shadowbox docs.

I know the smarty is good, since it I am using the same if to display text on the page. I'd also like to have it load a shadowbox.

I can get everything done except the autoload of the shadowbox.

I found this post... but I can't make it work.

What's the secret word, or magic handshake?

Thanks,

Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #2  
Old 03-25-2009, 06:21 AM
  TBone's Avatar 
TBone TBone is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 38
 

Default Re: Open a Shadowbox upon entering a page - with a smarty IF

Did you put the javascript between literal tags?
__________________
_____________________________________________
www.webcreatives.nl | X-Cart Shops
X-Cart Versions 4.1.x | 4.2.x | 4.3.x | 4.4.x
Parallelweg 124-14, 1948 NN BEVERWIJK
The Netherlands
Reply With Quote
  #3  
Old 03-25-2009, 06:39 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Open a Shadowbox upon entering a page - with a smarty IF

Yes. Of course. I have it working on a regular html page. Just starting to try to port it over to xcart.

This is a basic example of how it can work...

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script type="text/javascript" src="/shadowbox/adapter/shadowbox-base.js"></script> <script type="text/javascript" src="/shadowbox/shadowbox.js"></script> <script type="text/javascript"> Shadowbox.loadSkin('classic', '/shadowbox/skin'); Shadowbox.loadLanguage('en', '/shadowbox/lang'); Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], '/shadowbox/player'); window.onload = function(){ Shadowbox.init(); Shadowbox.open({ player: 'html', title: 'Hello World!', content: '<div style="border: 2px solid #FF07CE; width: 188; height: 188; padding: 4px; background-color: #FBDFFF; "><p>Hello World!</p></div>', height: 200, width: 200 }); }; </script> <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"> <title>Hello World!</title> </head> <body bgcolor="#ffffff"> <p>Hello World</p> </body> </html>

So, for xcart, I took the script and made it an include, and wrapped it in a {literal}. But no joy yet.

I think I'm close to figuring it out though, and I will report back.
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #4  
Old 03-25-2009, 07:09 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Open a Shadowbox upon entering a page - with a smarty IF

I had shadowbox working fine, with the following:

1. in skin1/customer/home.tpl - immediately after <head>

{* SHADOWBOX INCLUDE *}
{include file="shadowbox_include.tpl" }
{* END-SHADOWBOX INCLUDE *}

2. Contents of shadowbox_include.tpl:

Code:
{literal} <script type="text/javascript" src="/shadowbox/adapter/shadowbox-base.js"></script> <script type="text/javascript" src="/shadowbox/shadowbox-2.js"></script> <script type="text/javascript"> Shadowbox.loadSkin('classic', '/shadowbox/skin'); Shadowbox.loadLanguage('en', '/shadowbox/lang/shadowbox-en.js'); Shadowbox.loadPlayer(['flv'], ['img'], ['html'], ['iframe'], '/shadowbox/player'); window.onload = function(){ Shadowbox.init(); }; </script> {/literal}

THIS WORKS FINE. Shadowbox loads as expected, if called from an <a rel=shadwobox> tag.

So, I thought, why not make an if and look for a smarty variable? The var works as expected... but shadowbox does not seem to like being called like this...

In /customer/home.tpl, immediately after <head>

Code:
{* SHADOWBOX INCLUDE *} {if $smarty.get.reviewed eq "yes"} {include file="shadowbox_include-review-confirm.tpl" } {else} {include file="shadowbox_include.tpl" } {/if} {* END-SHADOWBOX INCLUDE *}

then shadowbox_include-review-confirm.tpl looks like:

Code:
{literal} <script type="text/javascript" src="/shadowbox/adapter/shadowbox-base.js"></script> <script type="text/javascript" src="/shadowbox/shadowbox-2.js"></script> <script type="text/javascript"> Shadowbox.loadSkin('classic', '/shadowbox/skin'); Shadowbox.loadLanguage('en', '/shadowbox/lang/shadowbox-en.js'); Shadowbox.loadPlayer(['flv'], ['img'], ['html'], ['iframe'], '/shadowbox/player'); window.onload = function(){ Shadowbox.init(); Shadowbox.open({ player: 'html', title: 'Hello World!', content: '<div style="border: 2px solid #FF07CE; width: 188; height: 188; padding: 4px; background-color: #FBDFFF; "><p>Hello World!</p></div>', height: 200, width: 200 }); }; </script> {/literal}

Does not do anything.

The code works on its own, but not when called in xcart.

What am I missing. Anyone care to try this?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #5  
Old 03-25-2009, 10:53 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Open a Shadowbox upon entering a page - with a smarty IF

Ok... making progress.

Copying code from the internet can put all kinds of invisibles into the code... depending on the browser used...


So I have a version working, now that I looked at the code with invisibles showing *(thank you Safari 4 js debug for that)... now I need to integrate it with an IF. I'll be back...
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #6  
Old 03-25-2009, 11:12 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Open a Shadowbox upon entering a page - with a smarty IF

OK, now we're cooking with gas.

This is freaking awesome!

However, I can't figure out how to pass a language var to the shadowbox open script, because it loads before the page. Hmm... BRB.
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #7  
Old 03-25-2009, 11:57 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Open a Shadowbox upon entering a page - with a smarty IF

Wow this is cool.
Playing with hidden divs, so that the content can live anywhere, but the script is universal. Language vars work.
I haven't been this thrilled about code in years.
This is one of the biggest user interface improvements I've been able to make for xcart. The customer experience is simply much cleaner now.

THIS is also the core of the solution for replacing the hideous, dialog_message.tpl

More to come...

Anyone want to see the work-in-progress? Just PM me.
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:29 AM.

   

 
X-Cart forums © 2001-2020