Your question is strange... You just add it. If you don't even know, how to work with HTML, I wouldn't suggest you to do it yourself.
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
Well, next time, you might better look in the OC Extension Section first:
Ernie
---
Custom CSS by viethemes
https://www.opencart.com/index.php?rout ... n_id=20565
Custom JavaScript by viethemes
https://www.opencart.com/index.php?rout ... n_id=20566
Add CSS Code From Admin / Backend
https://www.opencart.com/index.php?rout ... n_id=25114
Add Javascript From Admin / Backend
https://www.opencart.com/index.php?rout ... n_id=28366
Custom CSS, Javascript and Code
https://www.opencart.com/index.php?rout ... n_id=26410
Ernie
---
Custom CSS by viethemes
https://www.opencart.com/index.php?rout ... n_id=20565
Custom JavaScript by viethemes
https://www.opencart.com/index.php?rout ... n_id=20566
Add CSS Code From Admin / Backend
https://www.opencart.com/index.php?rout ... n_id=25114
Add Javascript From Admin / Backend
https://www.opencart.com/index.php?rout ... n_id=28366
Custom CSS, Javascript and Code
https://www.opencart.com/index.php?rout ... n_id=26410
My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Thank you so much Johnathan
I added the code in the same location. I have a question. is it effective for all other pages like products, products category ?
Thank you
hello, I would like to put a .js code before </html> for a mailerlite popup for the newsletter. I mention that I tried from the file /catalog/view/theme/fastor/template/common/header.tpl but I didn't succeed. Can someone help me? Thanks
The js code is:
<!-- MailerLite Universal -->
<script>
(function(w,d,e,u,f,l,n){w[f]=w[f]||function(){(w[f].q=w[f].q||[])
.push(arguments);},l=d.createElement(e),l.async=1,l.src=u,
n=d.getElementsByTagName(e)[0],n.parentNode.insertBefore(l,n);})
(window,document,'script','https://assets.mailerlite.com/js/universal.js','ml');
ml('account', '115781');
</script>
<!-- End MailerLite Universal -->
The js code is:
<!-- MailerLite Universal -->
<script>
(function(w,d,e,u,f,l,n){w[f]=w[f]||function(){(w[f].q=w[f].q||[])
.push(arguments);},l=d.createElement(e),l.async=1,l.src=u,
n=d.getElementsByTagName(e)[0],n.parentNode.insertBefore(l,n);})
(window,document,'script','https://assets.mailerlite.com/js/universal.js','ml');
ml('account', '115781');
</script>
<!-- End MailerLite Universal -->
You can use my code, in which I added also User Agent and Mobile detection:
Put this in HEADER.PHP right before:
Then visualize in Twig with this:
For example - replace <body> with:
Code: Select all
if (isset($this->request->get['route'])) {
$class = explode('/', $this->request->get['route']);
$id = $class[1];
$class = implode(' ', array_splice($class, 1));
if (isset($this->request->get['information_id'])) {
$this->load->model('catalog/information');
$information_id = '_' . $this->request->get['information_id'];
$class .= str_replace('/', '-', $information_id);
} else if (isset($this->request->get['product_id'])) {
$product_id = '_' . $this->request->get['product_id'];
$class .= ' ' . str_replace('/', '-', $id . $product_id);
} else {
$class .= ' ' . str_replace('/', '-', $this->request->get['route']);
}
if (isset($this->request->get['path'])) {
$this->load->model('catalog/category');
$cats = explode('_', $this->request->get['path']);
$cats = !is_array($cats) ? array($cats) : $cats;
foreach ($cats as $cat) {
$model = $this->model_catalog_category->getCategory($cat);
$class .= ' ' . str_replace(' ', '-', preg_replace('/[^a-z0-9\s]/', '', strtolower($model['name'])));
}
}
} else {
$class = 'home common-home';
$id = 'home';
}
// Detect user agent and add appropriate classes
$user_agent = $_SERVER['HTTP_USER_AGENT'];
// Detect browser
if (strpos($user_agent, 'MSIE') !== false || strpos($user_agent, 'Trident') !== false) {
$browser_class = 'ie';
} elseif (strpos($user_agent, 'Firefox') !== false) {
$browser_class = 'firefox';
} elseif (strpos($user_agent, 'Chrome') !== false) {
$browser_class = 'chrome';
} elseif (strpos($user_agent, 'Safari') !== false) {
$browser_class = 'safari';
} elseif (strpos($user_agent, 'Opera') !== false || strpos($user_agent, 'OPR') !== false) {
$browser_class = 'opera';
} else {
$browser_class = 'unknown-browser';
}
// Detect OS
if (strpos($user_agent, 'Windows') !== false) {
$os_class = 'windows';
} elseif (strpos($user_agent, 'Macintosh') !== false) {
$os_class = 'mac';
} elseif (strpos($user_agent, 'Linux') !== false) {
$os_class = 'linux';
} elseif (strpos($user_agent, 'iPhone') !== false || strpos($user_agent, 'iPad') !== false) {
$os_class = 'ios';
} else {
$os_class = 'unknown-os';
}
// Detect device (mobile or desktop)
if (strpos($user_agent, 'Mobile') !== false) {
$device_class = 'mobile';
} else {
$device_class = 'desktop';
}
// Concatenate all classes
$class .= ' ' . $browser_class . ' ' . $os_class . ' ' . $device_class;
$data['customstyle'] = ' id="' . $id . '" class="' . $class . '" ';
Code: Select all
return $this->load->view('common/header', $data);
Code: Select all
{{customstyle}}
Code: Select all
<body {{customstyle}}>
------------------------------
Still a Noobie...
My page: http://designninja.net Graphic designer services made easy!
Who is online
Users browsing this forum: No registered users and 278 guests