Очередной маленький мой хак для редактора категорий. Сейчас - приятный выбор иконки для категории заместо обычного ввода ссыкли на иконку.
Пробовал на версиях 7.5, 8.0, 8.2, 8.3
Итак, начинаем:
Открываем файл engine\skins\default.js и в начало файла вставляем:
function ShowOrHide2(d1) {
if (d1 != '') DoDiv2(d1);
}
function DoDiv2(id) {
var item = null;
if (document.getElementById) {
item = document.getElementById(id);
} else if (document.all){
item = document.all[id];
} else if (document.layers){
item = document.layers[id];
}
if (!item) {
}
else if (item.style) {
if (item.style.display == "none"){ item.style.display = ""; }
else {item.style.display = "none"; }
}else{ item.visibility = "show"; }
}
function inserticon(a,b)
{
document.getElementById(b).value=a;
$("#"+b).focus()
}
if (d1 != '') DoDiv2(d1);
}
function DoDiv2(id) {
var item = null;
if (document.getElementById) {
item = document.getElementById(id);
} else if (document.all){
item = document.all[id];
} else if (document.layers){
item = document.layers[id];
}
if (!item) {
}
else if (item.style) {
if (item.style.display == "none"){ item.style.display = ""; }
else {item.style.display = "none"; }
}else{ item.visibility = "show"; }
}
function inserticon(a,b)
{
document.getElementById(b).value=a;
$("#"+b).focus()
}
2. Потом открываем файл engine\inc\categories.php
Ищем строчку (по дефлоту строчка #306):
<input class="edit" value="{$row['icon']}" type="text" name="cat_icon"><a href="#" class="hintanchor" onmouseover="showhint('{$lang[hint_caticon]}', this, event, '250px')">[?]</a>
Заменяем на:
<input class="edit" value="{$row['icon']}" type="text" name="cat_icon" id="cat_icon"><a href="#" class="hintanchor" onmouseover="showhint('{$lang[hint_caticon]}', this, event, '250px')">[?]</a>
<br>
<a href="javascript:ShowOrHide2('icolist');javascript:ShowOrHide2('title');javascript:ShowOrHide2('title2');"><div id="title">[ Избрать значек ]</div><div id="title2" style="display:none;">[ Свернуть ]</div></a>
<br/>$iconlist
<br>
<a href="javascript:ShowOrHide2('icolist');javascript:ShowOrHide2('title');javascript:ShowOrHide2('title2');"><div id="title">[ Избрать значек ]</div><div id="title2" style="display:none;">[ Свернуть ]</div></a>
<br/>$iconlist
Дальше ищем строчку (по дефлоту строчка #483):
[?]
Заменяем на:
<input class="edit" onfocus="this.select()" value="$lang[cat_icon]" type="text" name="cat_icon" id="cat_icon"><a href="#" class="hintanchor" onmouseover="showhint('{$lang[hint_caticon]}', this, event, '250px')">[?]</a>
<br>
<a href="javascript:ShowOrHide2('icolist');javascript:ShowOrHide2('title');javascript:ShowOrHide2('title2');"><div id="title">[ Избрать значек ]</div><div id="title2" style="display:none;">[ Свернуть ]</div></a>
<br/>$iconlist
<br>
<a href="javascript:ShowOrHide2('icolist');javascript:ShowOrHide2('title');javascript:ShowOrHide2('title2');"><div id="title">[ Избрать значек ]</div><div id="title2" style="display:none;">[ Свернуть ]</div></a>
<br/>$iconlist
Ищем строчку (по дефлоту строчка #275):
$row['news_msort'] = makeDropDown( array ("" => $lang['sys_global'], "DESC" => $lang['opt_sys_mminus'], "ASC" => $lang['opt_sys_mplus'] ), "news_msort", $row['news_msort'] );
И опосля данной строчки, вставляем код:
$dir = ROOT_DIR.'/uploads/icons';
$columnsnum = 8;
if ($handle = opendir($dir))
{
$i = 0;
$iconlist = "<div id="icolist" style="display:none;"><table><tr>";
while (false !== ($file = readdir($handle)))
{
if ($file != '.' and $file != '..' and $file != '.htaccess' and $file != 'Thumbs.db' and $file != 'system' and $file != 'index.html')
{
$ext = explode(".", $file);
$icons = explode(",", $file);
foreach($icons as $iconame)
{
if(end($ext) == "gif" OR end($ext) == "png")
{
$i++; $iconame = trim($iconame);
$iconlist .= "<td align="center" style="padding:5px;"><img style="border: 0; cursor: pointer;" src="".$config['http_home_url']."uploads/icons/$iconame" alt="$iconame" onclick="inserticon('$config[http_home_url]uploads/icons/$iconame', 'cat_icon')" /></td>";
if ($i%$columnsnum == 0) $iconlist .= "</tr><tr>";
}
}
}
}
$iconlist .= "</tr></table></div>";
closedir($handle);
}
$columnsnum = 8;
if ($handle = opendir($dir))
{
$i = 0;
$iconlist = "<div id="icolist" style="display:none;"><table><tr>";
while (false !== ($file = readdir($handle)))
{
if ($file != '.' and $file != '..' and $file != '.htaccess' and $file != 'Thumbs.db' and $file != 'system' and $file != 'index.html')
{
$ext = explode(".", $file);
$icons = explode(",", $file);
foreach($icons as $iconame)
{
if(end($ext) == "gif" OR end($ext) == "png")
{
$i++; $iconame = trim($iconame);
$iconlist .= "<td align="center" style="padding:5px;"><img style="border: 0; cursor: pointer;" src="".$config['http_home_url']."uploads/icons/$iconame" alt="$iconame" onclick="inserticon('$config[http_home_url]uploads/icons/$iconame', 'cat_icon')" /></td>";
if ($i%$columnsnum == 0) $iconlist .= "</tr><tr>";
}
}
}
}
$iconlist .= "</tr></table></div>";
closedir($handle);
}
Потом Ищем строчку (по дефлоту строчка #481):
$skinlist = SelectSkin( '' );
И опосля данной строчки, вставляем код:
$dir = ROOT_DIR.'/uploads/icons';
$columnsnum = 8;
if ($handle = opendir($dir))
{
$i = 0;
$iconlist = "<div id="icolist" style="display:none;"><table><tr>";
while (false !== ($file = readdir($handle)))
{
if ($file != '.' and $file != '..' and $file != '.htaccess' and $file != 'Thumbs.db' and $file != 'system' and $file != 'index.html')
{
$ext = explode(".", $file);
$icons = explode(",", $file);
foreach($icons as $iconame)
{
if(end($ext) == "gif" OR end($ext) == "png")
{
$i++; $iconame = trim($iconame);
$iconlist .= "<td align="center" style="padding:5px;"><img style="border: 0; cursor: pointer;" src="".$config['http_home_url']."uploads/icons/$iconame" alt="$iconame" onclick="inserticon('$config[http_home_url]uploads/icons/$iconame', 'cat_icon')" /></td>";
if ($i%$columnsnum == 0) $iconlist .= "</tr><tr>";
}
}
}
}
$iconlist .= "</tr></table></div>";
closedir($handle);
}
$columnsnum = 8;
if ($handle = opendir($dir))
{
$i = 0;
$iconlist = "<div id="icolist" style="display:none;"><table><tr>";
while (false !== ($file = readdir($handle)))
{
if ($file != '.' and $file != '..' and $file != '.htaccess' and $file != 'Thumbs.db' and $file != 'system' and $file != 'index.html')
{
$ext = explode(".", $file);
$icons = explode(",", $file);
foreach($icons as $iconame)
{
if(end($ext) == "gif" OR end($ext) == "png")
{
$i++; $iconame = trim($iconame);
$iconlist .= "<td align="center" style="padding:5px;"><img style="border: 0; cursor: pointer;" src="".$config['http_home_url']."uploads/icons/$iconame" alt="$iconame" onclick="inserticon('$config[http_home_url]uploads/icons/$iconame', 'cat_icon')" /></td>";
if ($i%$columnsnum == 0) $iconlist .= "</tr><tr>";
}
}
}
}
$iconlist .= "</tr></table></div>";
closedir($handle);
}
Потом Ищем строчку (по дефлоту строчка #726):
echo "<img border=0 src="" . $cat_info[$id]['icon'] . "" height=40 width=40 alt="" . $cat_info[$id]['icon'] . "">";
Заменяем на:
echo "<img border=0 src="" . $cat_info[$id]['icon'] . "" alt="" . $cat_info[$id]['icon'] . "">";
Дальше создаем каталог icons в папке uploads и загружаем туда нужные Для вас иконки в форматах gif либо png.
Готово! Вы также сможете пользоваться измененными (готовыми) файлами:
Уважаемый посетитель, Вы зашли на сайт как незарегистрированный пользователь. Мы рекомендуем Вам зарегистрироваться либо зайти на сайт под своим именем.
| #1 написал: MaGiS (27 января 2010 21:06) | |
|---|---|
|
Группа: Гости Регистрация: -- |
Нормально...) Спасибо
|
| ICQ: -- | |
| #2 написал: dimchik (19 апреля 2010 20:27) | |
|---|---|
|
Группа: Гости Регистрация: -- |
Parse error: syntax error, unexpected T_STRING in K:\home\test1.ru\www\engine\inc\categories.php on line 281 поесле установки етого хака видало вот такую ошибку. как поправить вот 281 строчка.
$iconlist = "< div id = "icolist" style="display:none;"><table><tr>"; версия дле 8.5 |
| ICQ: -- | |
