OpenCart: How to move search field to top menu (content_top.tpl)

Please read this article to learn how to easy move search field to another part of your page. In my case I will move it to my custom menu. First you need to copy the code for the search form from: /catalog/view/theme/-yourtheme-/template/common/header.tpl Code: <div id=”search”> <div class=”button-search”></div> <?php if ($filter_name) { ?> <input type=”text” name=”filter_name” … Read more

Make username field active when entering the admin login page

OpenCart already uses jquery so all you need to is to pass focus() function to input username to make it focus on the username field. Here is how to do it. Open the following file in your favorite php editor: /admin/view/template/common/login.tpl and copy/paste this code: Code: $(document).ready(function() { $(“input[name=username]”).focus(); });

Facebook custom share button

Here is en example code on how to make a custom facebook share button. Code: <script>function fbs_click() {u=location.href;t=document.title;window.open(‘https://www.facebook.com/sharer.php?u=’+encodeURIComponent(u)+’&t;=’+encodeURIComponent(t),’sharer’,’toolbar=0,status=0,width=626,height=436′);return false;}</script><a href=’https://www.facebook.com/share.php?u=<url>’ onclick=’return fbs_click()’ target=’_blank’><img src=’SOURCE_TO_YOUR_IMAGE’ alt=’facebook’ title=’Share on facebook’ /></a></script>

Close prettyPhoto window from an iframe

Around the forums has been discussed on how to close prettyPhoto modal from within an iframe. I’ve tried many of solutions posted there without success. Here’s one solutions on how to do it. To close prettyPhoto from an iframe just call the following: <script type=”text/javascript”> parent.eval(‘$.prettyPhoto.close()’); </script>

Detect left mouse button click with jQuery

This script below will detect left mouse click and pop up an alert when you left click on the link “Click me”. Code: <script> $(function(){ $(“#click-me”).live(‘click’, function(e) { if( e.button == 0 ) { // Clicked with left mouse button alert(‘You clicked with left mouse button’); } }); }); </script> <a id=”click-me”>Click me</a>

Disable enter key in a form

ubuntudog-javascript-cookies-1030x579

There are two simple ways to disable enter key in your forms. 1. The first one is a piece of javascript that you include in your head section. <script language=”JavaScript”>function disableEnterKey(e){var key;if(window.event)key = window.event.keyCode; //IEelsekey = e.which; //firefoxif(key == 13)return false;elsereturn true;} 2. Than in the form issue onKeyPress like this: <input type=”text” onkeypress=”return disableEnterKey(event)”> … Read more