X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   HELP-The CLICK function in my script wont work (https://forum.x-cart.com/showthread.php?t=70015)

moetser 09-17-2014 06:27 PM

HELP-The CLICK function in my script wont work
 
2 Attachment(s)
Hi-I have an html file with a script that will overlay and display a box asking Are you 18 years or older? then there is a YES and a NO button -if you click YES the overlay disappears and you can see the site. If you click NO you are redirected to google.com

The html file on my local hard drive runs fine in a browser and you can click YES or NO and it does what it is supposed to.{other than the yes no images not directed correctly, that I can fix.

However, when I attempt to insert this into my home.tpl file everything other than the CLICK function works just fine. But you cannot click yes or no.

I know NOTHING and I mean NOTHING about java, scripting, php, I slightly comprehend a LITTLE html so any help would be so appreciated.

I ahve attached the 2 files-the pop18Clickworks.html is the file that works independently in a browser. The homeclick.tpl file is my home.tpl located in my skin/customer directory

Please help me, I know this is a simple script, syntax or format error and that I do not understand-it is all a foreign language to me

Thank you so much in advance for any assistance

Debbie
Xcart Gold Attachment 3929Attachment 3930

totaltec 09-17-2014 06:37 PM

Re: HELP-The CLICK function in my script wont work
 
No problem.

I think this is because X-cart's Smarty template engine is attempting to parse the {} tags in your JS code. Try wrapping it with {literal}{/literal} tags. Additionally you have used {} to display your script tags, when it should be <>. And finally you have included jQuery, and jQuery is already included in X-cart, and it should only be included once.

So you have not made one, but 3 separate errors! I think you should win a gold star. :-)
Try this code, replacing everything you put after {include file="customer/pop18.html"}:
Code:

<script type="text/javascript">
{literal}
$(document).ready(function(){

  $( ".popup_img_yes" ).click(function() {
    $( ".popup" ).fadeOut( 1200 );
  });
 
  $( ".popup_img_no" ).click(function() {
    window.open("http://www.google.com","_self");
  });

});
{/literal}
</script>


So you also need to remove this line: {script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'}{/script}

And I'm not sure about including a .html file like you have here: {include file="customer/pop18.html"}

I would rename that file to pop18.tpl and pull it in with:
{include file="customer/pop18.html"}

But it may be fine, I've never tried to include a .html file before. Leave it that way at first and tell me if it worked!

moetser 09-17-2014 07:00 PM

Re: HELP-The CLICK function in my script wont work
 
WOW ALMOST ALL FIXED-just 1 last thing- now it all works with just one problem left-it is supposed to clear the overlay when you click YES that works fine-but it is doing the same thing for when you click NO-When you click NO it is to redirect to google.com-

But now it just clears the overlay no matter which one you click see quietcricketus.com

How can i fix that?

MIKE YOU ARE MY NEW BEST FRIEND!!!! I have been trying for months to find a way to get that restriction on the home page. I cannot thank you enough!!

moetser 09-17-2014 07:07 PM

Re: HELP-The CLICK function in my script wont work
 
I removed the include html file as it does not work in the home.tpl

however the html file run directly in a browser does redirect to google.com
but the same exact code in the home.tpl is not redirecting to google.com whn you click NO it clears the overlay the same as when you click YES

I cannot figure out why

moetser 09-17-2014 07:34 PM

Re: HELP-The CLICK function in my script wont work
 
Just noticed another problem-I only have this in the home.tpl- however, the same popup keeps coming up everytime you click on any and all pages

why would it do that if I only have the code in home.tpl? is it fixable?

totaltec 09-17-2014 08:13 PM

Re: HELP-The CLICK function in my script wont work
 
Cool, you have an online vape shop. Sweet.

Sure if the code is in home.tpl, it will be called on every page. customer/home.tpl is the container for every customer side page.

If you want to restrict it to the home page, you need to add an if statement around all the code.
Code:

{if $main eq "catalog" and $current_category.category eq ""}
  All your code above goes here
{/if}


moetser 09-17-2014 08:18 PM

Re: HELP-The CLICK function in my script wont work
 
Yes, we are just starting out, but if you can have a discount for life!

I will try to enter that if statement and be right back- not exactly sure where it goes, we will see lol

What about when you click on the NO button it does not redirect to google like it is supposed to it just fades the overlay away like when you click yes-

in the independent html file in a browser it redirects to google when you click no, but does not in the home.tpl file

totaltec 09-17-2014 08:19 PM

Re: HELP-The CLICK function in my script wont work
 
Debbie,
I just read through your file pop18Clickworks.txt

That file contains a <html> tag <head> tag, and so on. You should not be including all of that stuff!

To explain, your home.tpl already has all those pieces, if you include them a second time it will make for a poorly formatted web page. Rename the file to .tpl, and include only the div class="popup"

Just this part:
Code:

<div class="popup"> <!-- popup content start || copy this to the end of the file-->
        <div class="popupWindow">
                <div class="popup_txt">
                        Are you 18 years of age or older?
                </div>
                <div class="popup_img">
                        <img src="/skin/my_skin/images/yes.png"  class="popup_img_yes"/>
                        <img src="/skin/my_skin/images/no.png"  class="popup_img_no"/>

                </div>
        </div>

</div>

Then you need to take the style out and include that in your home.tpl/ It would be better to include it via an external style sheet.

moetser 09-17-2014 08:30 PM

Re: HELP-The CLICK function in my script wont work
 
1 Attachment(s)
ok-I am attaching the home.tpl as it stands now for you to see

I am not using or calling the pop18 html file I took that "include" out

yeah I had already removed all the STYLE stuff to the css file

so here is the only file i am using which is the home.tpl file attached

I am sure I entered the if statement wrong lol

also, the popup comes up on the home page and when you click it clears out the overlay

but when you click NO it is not redirecting to google.com

the popup is still coming up on all the other pages, only you cannot click it to make it go away

please see attached file that I apparently screwed up

Attachment 3931

moetser 09-17-2014 08:31 PM

Re: HELP-The CLICK function in my script wont work
 
oops sorry I am sleepy-that one still has the style nonsense in it-I am removing it now


All times are GMT -8. The time now is 06:59 AM.

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