All posts by Jawad Rehman

 A Software Engineer having great experience with all the stages of SDLC including designing, developing, testing software's.  Result oriented, self driven, highly motivated, smart and hungry to learn new technologies, methodologies, strategies and processes.

Center links in navbar bootstrap

I have used navbar in footer and want to center the links used in the navbar. I have tried with centering the links using margin technique but it was not possible so finally i found a solution using display as table and table layout as fixed then links moved to center. Following is the code;

Code

Priview the page

 

Customer email address to success.tpl in OpenCart

It can be done using the following code;

/catalog/controller/checkout/success.php

$this->load->model(‘account/order’);
$order = $this->model_account_order->getOrder($this->session->data[‘order_id’]);
if($order) {
$this->data[’email’] = $order[’email’];
}

 

In your template /catalog/view/theme/your-theme-name/template/common/success.tpl you need to put

<?php if(!empty($email)) echo $email; ?>

Image path Opencart

Question
I’m editing this file header.tpl inside /template/common uploaded the image at : /catalog/view/theme/TEMPLATENAME/image and I need to add

Code:
<img src=”facebook.png”>
I tried Code:
<img src=”../image/facebook.png”>
and Code:
<img src=”../../image/facebook.png”>
but the image still doesn’t show. What’s the correct image path?

Answers
all files are served from index.php so (the root)therefore your image src would be:

Code:
<img src=”catalog/view/theme/TEMPLATENAME/image/facebook.png”>
unless you are using the image in a stylesheet, then it would be Code:
url(“../image/facebook.png”)
it worked!

Regular Expression Examples

1.

.

Any character

2.

\.
dot character

3.

+

One or more character

4.

*

Zero or more characters

5.

H.+H
Greedy

6.

H.+?H

Non greedy

7.

^
not and also used as beginning of string.

8.

$

End of string

9.

Numbers in the format [12345-1234]
[\d]{5}-[\d]{4}

10.

Numbers in format[12345-1234(optional])
^[\d]{5}(?:-[\d]{4})?$

11.

Email
\w+@\w+\.\w{1,3}
^.+?@.+\.[a-z]{2,4}$

12.

Repeating words (is is)
([a-z]+)\s+\1

13.

Date (day/month/year-12/04/2014)
(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[0-1])\/([0-9]{4})

14.
Time (12:00 PM)

(1[0-2]|0?[1-9]):([0-5][0-9])\s([PA]M)

15.

IP
192.168.1.1
([0-9]{1,3}\.){3}[0-9]{1,3}

16.
URL

https://www.googe.com
http://www.googe.com
file://www.googe.com

(https?|ftp|file)://.+$

17.
file with image extension

^.+(jpg|gif|png)$

(^.+(jpg|gif|png)$)

18.
href=([“‘])([^”‘]+)([“‘])

<a href=”www.google.com” title=”this” >

19.

display:box;
box-shadow:1px 2px 3px black;
box-sizing:100% 100%;

^box-(shadow|sizing)[^;]+
^box-(shadow|sizing).+$

20.

Negative look behind
display:box;box-shadow:1px 2px 3px black;box-sizing:100% 100%;
(?<!:)box[^;]+

21.

postive look ahead

jawad@gmail.com
ali@yahoo.com

@.+(?=\.[a-z]{2,4})

22.

Negative look behind

jawad@gmail.com
ali@gmail.com
jawad@hotmail.com

(?<!jawad)@.+

23.

Positive look behinde
(?<=jawad)@.+

24.

Positive look behind
box-sizing
shape-sizing
(?<=box-)sizing

25.

negative look behind
(?<!box-)sizing

26.

positive look ahead

box-sizing
box-shadow

box(?=-shadow)

27.

negative look head

box(?!-shadow)

Check/Uncheck Group of CheckBoxes

Javascript Code

<!DOCTYPE html>
<html>
<head>
<title>Check and Uncheck ALL check Boxes</title>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

<script type=”text/javascript”>
function checkAll(formname, checktoggle)
{
var checkboxes = new Array();
checkboxes = document.forms[formname].getElementsByTagName(‘input’);

for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type === ‘checkbox’) {
checkboxes[i].checked = checktoggle;
}
}
}
</script>
</head>
<body>
<form name=”myform”>
<li>
<label >
<a href=”javascript:void();” onclick=”javascript:checkAll(‘myform’, true);”>Check All</a> |
<a href=”javascript:void();” onclick=”javascript:checkAll(‘myform’, false);”>UnCheck All</a>
</label>
</li>
<li>
<input type=”checkbox” name=”content1″ value=”1″>
</li>
<li>
<input type=”checkbox” name=”content2″ value=”2″>
</li>
<li>
<input type=”checkbox” name=”content3″ value=”3″>
</li>
</form>
</body>
</html>

JQuery Code

<!DOCTYPE html>
<html>
<head>
<title>Check and Uncheck ALL check Boxes</title>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<script src=”jquery-1.11.3.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){
$(“#checkall”).click(function () {
$(‘input:checkbox’).not(this).prop(‘checked’, this.checked);
});

});
</script>
</head>
<body>
<form name=”myform”>
<li>

<input type=”checkbox” id=”checkall” name=”checkall”>
<label >check/uncheck</label>
</li>
<li>
<input type=”checkbox” name=”content1″ value=”1″/>
</li>
<li>
<input type=”checkbox” name=”content2″ value=”2″/>
</li>
<li>
<input type=”checkbox” name=”content3″ value=”3″/>
</li>
</form>
</body>
</html>