RewriteEngine on
# если не существующий файл
RewriteCond %{REQUEST_FILENAME} !-f
# если не существующая директория
RewriteCond %{REQUEST_FILENAME} !-d
# если не начинается с lp
RewriteCond %{REQUEST_URI} !^/lp/.*
# редирект с статусом 301; больше не выполнять правил
RewriteRule . /lp/ [R=301,L]
<?php
$items = [
['ID'=>35, 'menu_item_parent'=>0],
['ID'=>38, 'menu_item_parent'=>35],
['ID'=>36, 'menu_item_parent'=>35],
['ID'=>39, 'menu_item_parent'=>36],
['ID'=>40, 'menu_item_parent'=>39],
['ID'=>41, 'menu_item_parent'=>39],
['ID'=>37, 'menu_item_parent'=>0],
];
function find_childrens($items, $parentItem) {
$ret = [];
foreach($items as $item) {
if ($item['menu_item_parent'] == $parentItem['ID']) {
$treeItem = $item;
$treeItem['subitems'] = find_childrens($items, $item);
$ret[] = $treeItem;
}
}
return $ret;
}
$tree = [];
foreach($items as $item) {
if ($item['menu_item_parent'] == 0) {
$treeItem = $item;
$treeItem['subitems'] = find_childrens($items, $item);
$tree[] = $treeItem;
}
}
echo '<pre>';
print_r($tree);
echo '</pre>';
echo '<hr>';
function printer($treeItem, $level) {
if ($level) echo str_repeat('--', $level);
echo $treeItem['ID'].'<br>';
if ($treeItem['subitems']) {
foreach($treeItem['subitems'] as $subItem) {
printer($subItem, $level+1);
}
}
}
foreach($tree as $treeItem) printer($treeItem, 0);
Array
(
[0] => Array
(
[ID] => 35
[menu_item_parent] => 0
[subitems] => Array
(
[0] => Array
(
[ID] => 38
[menu_item_parent] => 35
[subitems] => Array
(
)
)
[1] => Array
(
[ID] => 36
[menu_item_parent] => 35
[subitems] => Array
(
[0] => Array
(
[ID] => 39
[menu_item_parent] => 36
[subitems] => Array
(
[0] => Array
(
[ID] => 40
[menu_item_parent] => 39
[subitems] => Array
(
)
)
[1] => Array
(
[ID] => 41
[menu_item_parent] => 39
[subitems] => Array
(
)
)
)
)
)
)
)
)
[1] => Array
(
[ID] => 37
[menu_item_parent] => 0
[subitems] => Array
(
)
)
)
====================================================
35
-- 38
-- 36
---- 39
------ 40
------ 41
37
$query = 'SELECT tc_date, COUNT(tc_date) as amount FROM .. WHERE .. GROUP_BY tc_date';
$items = $sql->execute($query);
foreach($items as $item) {
echo $item['tc_date'] . ' = ' . $item['amount'] . '<br>';
}
<a href="http://site.com#tab-12">IMG</a>
var url = "http://site.com/index.php#tab-12";
var hash = url.substring(url.indexOf('#')+1);
alert(hash);
$(".aviation-img-cont").click(function(event){
event.preventDefault();
document.location.href='http://site.com/#tab-12'
});
$(function(){
var url = document.location.href;
var hash = url.substring(url.indexOf('#')+1);
if (hash=='tab-12') {
alert('Activate tab 12');
}
});
spl_autoload_register(function ($class) {
$file = __DIR__ . "/" . str_replace("\\", "/", $class) . '.php';
if ($class=='modules\datebase\connection') die($file); // <<<<<<<<<<<<<<<<<
if (is_file($file))
{
require_once $file;
}
});
var popupRendering = false;
$('.auth-login__yes').on('click',function(){
if (popupRendering) return; // если происходит rendering то выходим
popupRendering = true; // начинаем рендерить окно
$('.login-user').show("slide", { direction: "left" }, 1000, function(){
popupRendering = false; // рендеринг закончен
});
});
function renderProductDelivery($productItems) {
$html = '';
// логика рендеринга $product['delivery']
return $html;
}
<?php if ($product['delivery']): ?>
<label> Доставка: </label>
<?=renderProductDelivery($product['delivery']) ?>
<?php endif; ?>