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

moetser 09-17-2014 08:34 PM

Re: HELP-The CLICK function in my script wont work
 
1 Attachment(s)
HERE is the file without the style Attachment 3932 junk

totaltec 09-17-2014 08:39 PM

Re: HELP-The CLICK function in my script wont work
 
Debbie hang tight. I have fixed all the code and recorded you a video tutorial. You can see the code working at http://trainingpen.com

moetser 09-17-2014 08:43 PM

Re: HELP-The CLICK function in my script wont work
 
WOW you got it to work!!! AMAZING!! MONTHS OF TORTURE OVER!!

So how do I make it do that now lol

moetser 09-17-2014 08:44 PM

Re: HELP-The CLICK function in my script wont work
 
COOL A VIDEO- SO AWESOME OF YOU!! Where do I watch the video?

totaltec 09-17-2014 08:54 PM

Re: HELP-The CLICK function in my script wont work
 
Okay I have made a video showing you step by step how to do it.

http://youtu.be/AbqdI7U4bDo -it is still processing but once it is done (in a few minutes) you should be able to watch in hd and full screen so you can read the text easily.

This is the right way to do this. It could be improved by setting a cookie in the user's browser, but at least it works for what you need.

I like helping out anyway, but if you feel I have earned it, send me some PayPal love! Just paypal to mike@babymonkeystudios.com whatever you think is fair. I don't need a vaping discount I have 18 1-gallon jugs of e-liquid sitting on the shelf next to me. :-) http://nicqua.com is one of my companies. I do that on the side, but I make my living with X-cart.

moetser 09-17-2014 09:46 PM

Re: HELP-The CLICK function in my script wont work
 
WOW MIKE I REALLY APPRECIATE ALL YOUR HELP AND EFFORT!!!

I am really confused now, but it is just because I am REALLY tired here and my eyes are not working so good now. I think I better try and work on this tomorrow after sleeping ! Will get back with you tomorrow and let yo know how it goes.

Hopefully I can do it- You make it look so easy lol

Will check in with you tomorrow

thanks again so much,
Debbie

totaltec 09-17-2014 09:56 PM

Re: HELP-The CLICK function in my script wont work
 
Sounds good. Sleep will make it easier.

moetser 09-17-2014 10:02 PM

Re: HELP-The CLICK function in my script wont work
 
It seems to be working but clicking no fades away the overlay+it wont go to google, but code looks just like yours- why does yours go to google and mine doesnt? I made everything match what am I doing wrong

moetser 09-17-2014 10:06 PM

Re: HELP-The CLICK function in my script wont work
 
im blind now must go to bed-again, thank you so much. I know you are tired as well. I will get with you tomorrow!

U R AMAZING!

moetser 09-18-2014 02:27 PM

Re: HELP-The CLICK function in my script wont work
 
AWESOME IT WORKS!!!

Thank you so much Mike-the video really helped make it easier. I did not realize it would involve so much of your time, I thought it was just a simple error that someone could answer. I realize that your time is expensive.

Had I known I would not have bothered, I thought people were on the forums sharing information.

I do not have any money as I am currently disabled{without disability}in desperate need of knee replacements.

Being stuck sitting down is why I started the vape business in order to try and survive. As you can see it is not even started yet.

I am banned from paypal because i used to sell on Ebay and paypal stole my money and I sued them so they banned me from their site.

If know you wouldnt want to post it on here, can you private message on here?or you could go on my site into contact us and send me an address so that if I can come up with a little something I could send it to you to thank you. I know I could never pay what your professional rates are. However if I find a way to make some money soon I would really like to send you something for being so nice and taking the time in the middle of the night to help a total stranger.

Yes, I am not just saying that I really will find a way to send you something, somehow.

Most sincerely grateful,
Debbie

totaltec 09-18-2014 08:09 PM

Re: HELP-The CLICK function in my script wont work
 
Debbie, no worries, I am on here to freely share my info and knowledge, as well as learn myself. It all comes around. I certainly wouldn't refuse a tip if I have been helpful and the assets are there.

I'm glad you got it sorted out!

Good luck, and best wishes for e-commerce success. :-)

moetser 09-22-2014 06:55 AM

Re: HELP-The CLICK function in my script wont work
 
Mike -please send me an address you can email pmd2009@live.com

totaltec 09-23-2014 05:10 AM

Re: HELP-The CLICK function in my script wont work
 
Quote:

Originally Posted by moetser
Mike -please send me an address you can email pmd2009@live.com


I have sent you an email, but I don;t mind posting my address publicly. My address is:

Mike White
244 Fairfax Ave
Louisville, Ky 40207


All times are GMT -8. The time now is 05:28 AM.

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