Jump to content

How would I install this javascript?


noesac

Recommended Posts

This is one of those things that is easy if you know how to write modules, but not if you don't. You can read how to create a module here. If you can't create a module, you could copy the code into your theme, though that ties the code to that theme only. You could copy the HTML code and Javascript into footer.tpl and copy the CSS into global.css.

Link to comment
Share on other sites

Hi Rocky, it would probably be ok if it were tied to just one theme as I'm not looking to change themes anytime soon.

Wouldn't putting this in the footer display it at the bottom of the page instead of at the top?

I just added the css to global.css, and the following to the footer.tpl file but no luck, any idea what i've done wrong?

<!-- Footer -->


Hey, This is my Message.
X



$(document).ready(function() {
   $("#message").fadeIn("slow");
   $("#message a.close-notify").click(function() {
       $("#message").fadeOut("slow");
       return false;
   });
});
{$HOOK_FOOTER}

   {/if}
   </body>
</html>

Link to comment
Share on other sites

I thought since it is a message box, it should go at the bottom so it is loaded after the website finishes and doesn't block loading of the website. Try adding {literal} before the Javascript and {/literal} after so that Smarty doesn't get confused by the { } in the Javascript.

Link to comment
Share on other sites

Hum no luck, this is what I did:


<!-- Footer -->


Hey, This is my Message.
X



{literal}$(document).ready(function() {
   $("#message").fadeIn("slow");
   $("#message a.close-notify").click(function() {
       $("#message").fadeOut("slow");
       return false;
   });
});
{/literal}

{$HOOK_FOOTER}

   {/if}
   </body>
</html>




Here's my test site: http://tiny.cc/uq5qw


And here's a great example of it in action: http://stackoverflow.com/

(really nice way of doing notifications!!)

Link to comment
Share on other sites

I just noticed that you forgot to put script tags around your code. Try:

{literal}
<script type="text/javascript">
$(document).ready(function() {
   $("#message").fadeIn("slow");
   $("#message a.close-notify").click(function() {
       $("#message").fadeOut("slow");
       return false;
   });
});
</script>
{/literal}

Link to comment
Share on other sites

Great that worked!! Hum I just realised that it might not work all that well with prestashop...since I can't dynamically adjust my page up and down (if you look at my test site it looks a little funky).

Oh well maybe I can use it again in the future!:(

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...