Вы не зашли.
основная проблема с реализацией...знаний не хватает (
интуитивно понимаю что копать нужно тут /engine/includes/inc/functions.inc.php
function makeCategoryList($params = array() /*selected=0, $my=0, $noempty=0, $name='category'*/){
global $catz, $lang, $mysql;
if (!is_array($params['skip'])) { $params['skip'] = $params['skip']?array($params['skip']):array(); }
$name = array_key_exists('name', $params)?$params['name']:'category';
$out = "<select name=\"$name\" id=\"catmenu\"".($params['class']?' class="'.$params['class'].'"':'').">\n";
if ($params['doempty']) { $out.= "<option value=\"0\">".$lang['no_cat']."</option>\n"; }
if ($params['doall']) { $out.= "<option value=\"\">".$lang['sh_all']."</option>\n"; }
if ($params['resync']) {
$catz = array();
foreach ($mysql->select("select * from `".prefix."_category` order by posorder asc", 1) as $row) {
$catz[$row['alt']] = $row;
$catmap[$row['id']] = $row['alt'];
}
}
foreach($catz as $k => $v){
if (in_array($v['id'], $params['skip'])) { continue; }
$out.="<option value=\"".($params['nameval']?$v['name']:$v['id'])."\"".(($v['id']==$params['selected'])?' selected="selected"':'').">".str_repeat('— ', $v['poslevel']).$v['name']."</option>\n";
}
$out.="</select>";
return $out;
}
но чем копать и как - не понимаю )
Не в сети
/engine/includes/inc/functions.inc.php
#1. Найти
// makeCategoryList - make <SELECT> list of categories
// Params: set via named array
// * name - name field of <SELECT>
// * selected - ID of category to be selected
// * skip - ID of category to skip or array of IDs to skip
// * doempty - add empty category to the beginning ("no category"), value = 0
// * doall - all category named "ALL" to the beginning, value is empty
// * nameval - use DB field "name" instead of ID in HTML option value
// * resync - flag, if set - we make additional lookup into database for new category list
function makeCategoryList($params = array() /*selected=0, $my=0, $noempty=0, $name='category'*/){
global $catz, $lang, $mysql;
if (!is_array($params['skip'])) { $params['skip'] = $params['skip']?array($params['skip']):array(); }
$name = array_key_exists('name', $params)?$params['name']:'category';
$out = "<select name=\"$name\" id=\"catmenu\"".($params['class']?' class="'.$params['class'].'"':'').">\n";
if ($params['doempty']) { $out.= "<option value=\"0\">".$lang['no_cat']."</option>\n"; }
if ($params['doall']) { $out.= "<option value=\"\">".$lang['sh_all']."</option>\n"; }
if ($params['resync']) {
$catz = array();
foreach ($mysql->select("select * from `".prefix."_category` order by posorder asc", 1) as $row) {
$catz[$row['alt']] = $row;
$catmap[$row['id']] = $row['alt'];
}
}
foreach($catz as $k => $v){
if (in_array($v['id'], $params['skip'])) { continue; }
$out.="<option value=\"".($params['nameval']?$v['name']:$v['id'])."\"".(($v['id']==$params['selected'])?' selected="selected"':'').">".str_repeat('— ', $v['poslevel']).$v['name']."</option>\n";
}
$out.="</select>";
return $out;
}
#1. Добавить после
// makeCategoryBlock - make block of categories
// Params: set via named array
// * name - field name
// * selected - ID of category to be selected or array of IDs to be selected
// * skip - ID of category to skip or array of IDs to skip
// * resync - flag, if set - we make additional lookup into database for new category list
function makeCategoryBlock($params = array()){
global $catz, $mysql;
if (!is_array($params['selected'])) { $params['selected'] = $params['selected']?array($params['selected']):array(); }
if (!is_array($params['skip'])) { $params['skip'] = $params['skip']?array($params['skip']):array(); }
$name = array_key_exists('name', $params)?$params['name']:'categories';
$col = isset($params['col']) ? $params['col'] : 3;
$selected = implode(',', $params['selected']);
$out = "<input type=\"hidden\" name=\"$name\" id=\"categories\" value=\"$selected\" />\n";
if ($params['resync']) {
$catz = array();
foreach ($mysql->select("select * from `".prefix."_category` order by posorder asc", 1) as $row) {
$catz[$row['alt']] = $row;
$catmap[$row['id']] = $row['alt'];
}
}
foreach($catz as $k => $v){
if (in_array($v['id'], $params['skip'])) { continue; }
$out.="<div id=\"cat_{$v['id']}\" onclick=\"selectcat({$v['id']}); return false;\" class=\"catblock".(in_array($v['id'], $params['selected'])?'_selected':'')."\">".str_repeat('— ', $v['poslevel']).$v['name']."</div>";
}
return $out;
}
/engine/includes/js/functions.js
#2. Найти
function addcat(){
if (document.getElementById('categories').value != '' && document.getElementById('catmenu').value != '') {
document.getElementById('categories').value = document.getElementById('categories').value + ", " + document.getElementById('catmenu').value;
}
else if (document.getElementById('catmenu').value != '') {
document.getElementById('categories').value = document.getElementById('catmenu').value;
}
document.getElementById('catmenu').options[document.getElementById('catmenu').selectedIndex] = null;
if (document.getElementById('catmenu').options.length == 0) {
document.getElementById('catmenu').disabled = true;
document.getElementById('catbutton').disabled = true;
}
}
#2. Добавить после
var categories = new Array();
var className = '';
function selectcat(id){
if (id in categories && categories[id] != '') {
categories[id] = '';
document.getElementById('cat_' + id).className = className;
}
else {
categories[id] = id;
className = document.getElementById('cat_' + id).className;
document.getElementById('cat_' + id).className = className + '_selected';
}
document.getElementById('categories').value = categories.join(',');
}
/engine/actions/addnews.php
#3. Найти
'catlist' => makeCategoryList(array('nameval' => 1)),
#3. Добавить после
'catblock' => makeCategoryBlock(),
/шаблон/addnews.tpl (на примере default)
#4. Найти
<tr>
<td width="100%" style="padding: 3px;">{l_category} {catlist} <input type="button" name="catbutton" id="catbutton" value="{l_add}" class="button" onClick="addcat(); return false;" /></td>
</tr>
#4. Заменить на
<tr>
<td width="100%" style="padding: 3px;">{catblock}</td>
</tr>
#5. Добавить стили
.catblock {
float: left;
width: 33%; /* 100 / 33 = 3 категории в ряду */
}
.catblock_selected {
float: left;
width: 33%;
background: #ff0000; /* красный фон для выделенных категорий */
}
#6. Перейти в браузере по адресу: http://ваш_сайт/engine/includes/js/functions.js и нажать F5 (чтобы обновить functions.js в кэше браузере)
Enjoy!
Не в сети