X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Open a Shadowbox upon entering a page - with a smarty IF (https://forum.x-cart.com/showthread.php?t=46519)

carpeperdiem 03-24-2009 05:56 PM

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

TBone 03-25-2009 06:21 AM

Re: Open a Shadowbox upon entering a page - with a smarty IF
 
Did you put the javascript between literal tags?

carpeperdiem 03-25-2009 06:39 AM

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.

carpeperdiem 03-25-2009 07:09 AM

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?

carpeperdiem 03-25-2009 10:53 AM

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...
:evil: :evil: :evil:

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...

carpeperdiem 03-25-2009 11:12 AM

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.

carpeperdiem 03-25-2009 11:57 AM

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.


All times are GMT -8. The time now is 11:59 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.