document.querySelectorAll('ul')
.forEach(el => el.classList.toggle('show'));
const btnn = document.querySelector('#btnn');
btnn.addEventListener('click', () => {
[...document.querySelectorAll('ul')]
.forEach(el => el.classList.toggle('show'));
ul.classList.toggle('show');
btnn.classList.toggle('show');
});
$data['categories'] = array();
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
$children2_data = array();
$children2 = $this->model_catalog_category->getCategories($child['category_id']);
foreach ($children2 as $child2) {
$children3_data = array();
$children3 = $this->model_catalog_category->getCategories($child2['category_id']);
foreach ($children3 as $child3) {
$filter_data3 = array(
'filter_category_id' => $child3['category_id'],
);
$children3_data[] = array(
'category_id' => $child3['category_id'],
'name' => $child3['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data3) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']. '_' . $child2['category_id']. '_' . $child3['category_id'])
);
}
$filter_data2 = array(
'filter_category_id' => $child2['category_id'],
);
$children2_data[] = array(
'category_id' => $child2['category_id'],
'name' => $child2['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data2) . ')' : ''),
'children3' => $children3_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']. '_' . $child2['category_id'])
);
}
$filter_data1 = array(
'filter_category_id' => $child['category_id'],
);
$children_data[] = array(
'category_id' => $child['category_id'],
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data1) . ')' : ''),
'children2' => $children2_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
$filter_data = array(
'filter_category_id' => $category['category_id'],
);
$data['categories'][] = array(
'category_id' => $category['category_id'],
'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'children' => $children_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
<div class="list-group">
<?php foreach ($categories as $category) { ?>
<?php if ($category['category_id'] == $category_id) { ?>
<a href="<?php echo $category['href']; ?>" class="list-group-item active"><?php echo $category['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $category['href']; ?>" class="list-group-item"><?php echo $category['name']; ?></a>
<?php } ?>
<?php if (($category['children']) && ($category['category_id'] == $category_id)) { ?>
<?php foreach ($category['children'] as $child) { ?>
<?php if ($child['category_id'] == $child_id) { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item active"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item"> - <?php echo $child['name']; ?></a>
<?php } ?>
<?php if (($child['children2']) && ($category['category_id'] == $category_id)) { ?>
<?php foreach ($child['children2'] as $child2) { ?>
<?php if ($child2['category_id'] == $child_id2) { ?>
<a href="<?php echo $child2['href']; ?>" class="list-group-item active"> - <?php echo $child2['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child2['href']; ?>" class="list-group-item"> - <?php echo $child2['name']; ?></a>
<?php } ?>
<?php if (($child2['children3']) && ($category['category_id'] == $category_id)) { ?>
<?php foreach ($child2['children3'] as $child3) { ?>
<?php if ($child3['category_id'] == $child_id3) { ?>
<a href="<?php echo $child3['href']; ?>" class="list-group-item active"> - <?php echo $child3['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child3['href']; ?>" class="list-group-item"> - <?php echo $child3['name']; ?></a>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
</div>
<div class="col-md-8">
<div class="col-md-8 products">
<div class="col-sm-4">
<div class="product">
<div class="container content">
<div class="row">
<div class="col-md-4">
<div class="list-group">
<a href="{% url 'products:productsList' %}"
class="list-group-item {% if not category %}selected{% endif %}">Все</a>
{% for c in categories %}
<a href="{{ c.get_absolute_url }}"
class="list-group-item {% if category.id == c.id %}selected{% endif %}">{{ c.name }}</a>
{% endfor %}
</div>
</div>>
<div class="col-md-8 products">
<div class="row">
{% for product in products %}
<div class="col-sm-4">
<div class="product">
<div class="product-img">
<img src="{% if product.image %}{{ product.image.url }}{% else %}{% endif %}" alt="">
</div>
<p class="product-title">
<a href="{{ product.get_absolute_url }}">{{ product.title }}</a>
</p>
<p class="product-price">{{ product.price }} руб.</p>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<script>
$(function(){
$('a[href^="#"]').on('click', function(event) {
event.preventDefault();
var sc = $(this).attr("href"),
dn = $(sc).offset().top - 100;
$('html, body').animate({scrollTop: dn}, 1000);
});
});
</script>
$(this).addClass('currentActive');
var classname = document.getElementsByClassName('answer');
function myFunction(e){
document.querySelectorAll('.answer').forEach(ans => {
ans.style.background = '#222'
ans.style.color = '#aeaeae'
});
e.target.style.background = '#fff'
e.target.style.color = '#000'
}
for (var i = 0; i < classname.length; i++) {
classname[i].addEventListener('click', myFunction, false);
}
<form class="form-element",
$('#form-element').
<form id="form-element" class="form-element",
$data = $_POST;
if ($data['name']) {
$message = '<html><body>';
$message .= "<table>";
foreach ($data as $key => $value) {
$message .= "<tr>";
$message .= "<td>";
$message .= "<strong> $key: </strong>";
$message .= "</td>";
$message .= "<td style='padding-left:12px;'>";
$message .= " htmlspecialchars(trim($value))";
$message .= "</td>";
$message .= "</tr>";
}
$message .= "</table><br><br>";
$message .= "</body></html>";
require dirname(__DIR__).'/Exception.php';
require dirname(__DIR__).'/PHPmailer.php';
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->setFrom('no-reply@example.com', 'Mail title');
$mail->addAddress('John@mail.ru', 'John Doe');
$mail->Subject = $subject;
// Прикрепление файлов
if (isset($_FILES['photo']) &&
$_FILES['photo']['error'] == UPLOAD_ERR_OK) {
for($i=0;$i<count($_FILES['photo']['tmp_name']);$i++)
{
$uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['photo']['name'][$i]));
$filename =$_FILES['photo']['name'][$i];
if (move_uploaded_file($_FILES['photo']['tmp_name'][$i], $uploadfile)) {
$mail->addAttachment($uploadfile, $filename);
}
}
}
$mail->msgHTML($message);
$r = $mail->send();
if ($r) {
$answer = 'success';
} else {
$answer = 'failure';
}
die($answer);
}
document.getElementById('field').parentNode.classList.add("newclass");
<a href="АДРЕС СТРАНИЦЫ.html" class="open-popup-link">Показать всплывающее окно</a>
$('.open-popup-link').magnificPopup({
type:'ajax',
callbacks: {
parseAjax: function(mfpResponse) {
mfpResponse.data = $(mfpResponse.data).find('#какой-то элемент');
}
}
});
$('.open-popup-link').magnificPopup({
type:'ajax',
callbacks: {
parseAjax: function(mfpResponse) {
mfpResponse.data = $(mfpResponse.data).filter('#какой-то элемент');
}
}
});