Перейти к контенту

Show/Hide cat


Рекомендуемые сообщения

Доброго времени суток.

У меня стоит мод для скрытия категорий (+ -), с сохранением в кукисы, но вот проблемма. На статистику это не распространяется. Пытался уже несколько раз сделать сам, но либо получалось скрывать статистику но другие категории не работали, либо наоборот. ;)

Вообщем вот этот мод:

skin\s*\skin_boards.php
Find
function CatHeader_Expanded($Data) {
global $ibforums;
return <<<EOF
<div class="tableborder">
  <div class='maintitle' align='left'><{CAT_IMG}> <a href="{$ibforums->base_url}c={$Data['id']}">{$Data['name']}</a></div>
  <table width="100%" border="0" cellspacing="1" cellpadding="4">
	<tr> 
	  <th align="center" width="2%" nowrap="nowrap" class='titlemedium'><img src="{$ibforums->vars['img_url']}/spacer.gif" alt="" width="28" height="1" /></th>
	  <th align="left" width="59%" nowrap="nowrap" class='titlemedium'>{$ibforums->lang['cat_name']}</th>
	  <th align="center" width="7%" nowrap="nowrap" class='titlemedium'>{$ibforums->lang['topics']}</th>
	  <th align="center" width="7%" nowrap="nowrap" class='titlemedium'>{$ibforums->lang['replies']}</th>
	  <th align="left" width="25%" nowrap="nowrap" class='titlemedium'>{$ibforums->lang['last_post_info']}</th>
	</tr>
EOF;
}

Replace With

function CatHeader_Expanded($Data) {
global $ibforums;
return <<<EOF
<div id='b{$Data['id']}h' style='display:{$Data['contract_on']}'>
	<div class="tableborder">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr class='maintitle'>
			<td align='left'><{CAT_IMG}> <a href="{$ibforums->base_url}act=SC&c={$Data['id']}">{$Data['name']}</a></td>
			<td align='right'><a href="java script:ShowHide('b{$Data['id']}s','b{$Data['id']}h')"><{MAXI}></a>  </td>
		</tr>
		</table>
	</div>
	<br />
</div>
<div id='b{$Data['id']}s' style='display:{$Data['expanded_on']}'>
	<div class="tableborder">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr class='maintitle'>
			<td align='left'><{CAT_IMG}> <a href="{$ibforums->base_url}act=SC&c={$Data['id']}">{$Data['name']}</a></td>
			<td align='right'> <a href="java script:ShowHide('b{$Data['id']}s','b{$Data['id']}h')"><{MINI}></a>  </td>
		</tr>
		</table>
		<table width="100%" border="0" cellspacing="1" cellpadding="4">
		<tr> 
		  <th align="center" width="2%" class='titlemedium'><img src="{$ibforums->vars['img_url']}/spacer.gif" alt="" width="28" height="1" /></th>
		  <th align="left" width="59%" class='titlemedium'>{$ibforums->lang['cat_name']}</th>
		  <th align="center" width="7%" class='titlemedium'>{$ibforums->lang['topics']}</th>
		  <th align="center" width="7%" class='titlemedium'>{$ibforums->lang['replies']}</th>
		  <th align="left" width="25%" class='titlemedium'>{$ibforums->lang['last_post_info']}</th>
		</tr>
EOF;
}

Find

function end_this_cat() {
global $ibforums;
return <<<EOF
	 <tr> 
	  <td class='darkrow2' colspan="5"> </td>
	</tr>
  </table>
</div>
<br />
EOF;
}

Replace with

function end_this_cat() {
global $ibforums;
return <<<EOF
	 <tr> 
	  <td class='darkrow2' colspan="5"> </td>
	</tr>
  </table>
</div>
<br />
</div>
EOF;
}

Find

<div align='left' style='text-align:left;padding-bottom:4px'>
	<!-- IBF.NEWSLINK -->{$ibforums->lang['welcome_back_text']} $lastvisit
</div>

Add Above

<script language='javascript' type='text/javascript'>
<!--
var enam = "{$ibforums->vars['cookie_id']}";
// Home made cookie stuff
function writeCookie(name, value)
{
	var path = "{$ibforums->vars['cookie_path']}";
	var domain = "{$ibforums->vars['cookie_domain']}";
	var out = "";
	out = enam + name + "=" + escape(value) +  
	((path == "") ? "" : ("; path=" + path)) +  
	((domain == "") ? "" : ("; domain=" + domain));
	document.cookie = out;
}

function readCookie(name)
{
	var cookieValue = "";
	var search = enam + name + "=";
	if(document.cookie.length > 0)
	{ 
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
	return cookieValue;
}

function MakeCookie(id,visible)
{
	// Get a cookie array
	var acook = readCookie("boardlayout").split(",");
	var tmpa = new Array();
	var b = false;
	// Search the array for the cat id
	for (var i = 0; i < acook.length; i++) {
		//alert(acook[i].toString());
		tmpa = acook[i].split(".");
		if(tmpa[0]==id) {b=true;break;}
	}
	if(b==true) {
		tmpa[1]=visible;
		acook[i]=tmpa.join(".");
	}
	else {
		var tmpa = new Array();
		tmpa[0] = id;
		tmpa[1] = 1;
		acook.push(tmpa.join("."));
	}
	writeCookie("boardlayout",acook.join(","),null); 
}
// End Cookies
// show/hide a layer
function ShowHide(id1, id2) {
  if (id1 != '') expMenu(id1,1);
  if (id2 != '') expMenu(id2,0);
}

function expMenu(id,mc) {
	var itm = null;
	if (document.getElementById) itm = document.getElementById(id);
	else if (document.all) itm = document.all[id];
	else if (document.layers) itm = document.layers[id];

  if (!itm) {
   // do nothing
  }
  else if (itm.style) {
	if (itm.style.display == "none") 
	{	
		itm.style.display = ""; //make visible
		if(mc==1) {
			var pid = id.substr(1,id.length-2);
			MakeCookie(pid,1);
		}
	}
	else 
	{	itm.style.display = "none"; // scary now its gone;)
		if(mc==1) {
			var pid = id.substr(1,id.length-2);
			MakeCookie(pid,0);
		}
	}
  }
  else { itm.visibility = "show"; }
}
// End show/hide layers
//-->
</script>

Close & Save

Open sources\Boards.php
Find

function process_all_cats() {

	global $std, $DB, $ibforums;	

	foreach ($this->cats as $cat_id => $cat_data)
	{

		//----------------------------
		// Is this category turned on?
		//----------------------------

		if ( $cat_data['state'] != 1 )
		{
			continue;
		}

		foreach ($this->forums as $forum_id => $forum_data)
		{
			if ($forum_data['category'] == $cat_id)
			{
				//-----------------------------------
				// We store the HTML in a temp var so
				// we can make sure we have cats for
				// this forum, or hidden forums with a 
				// cat will show the cat strip - we don't
				// want that, no - we don't.
				//-----------------------------------

				$temp_html .= $this->process_forum($forum_id, $forum_data);
			}
		}

		if ($temp_html != "")
		{
			$this->output .= $this->html->CatHeader_Expanded($cat_data);
			$this->output .= $temp_html;
			$this->output .= $this->html->end_this_cat();
		}

		unset($temp_html);
	}

	$this->output .= $this->html->end_all_cats();

}

Replace with

function process_all_cats() {

	global $std, $DB, $ibforums;
	// Make a good cookie
	$cook = array(); $ecook = array(); $tmpa= array(); 
	$cook = explode(",",$std->my_getcookie('boardlayout'));
	foreach($cook as $e)
	{	
		$tmpa = explode(".",$e);
		$ecook[$tmpa[0]]=$tmpa;
	}
	$cook = array(); 
	foreach ($this->cats as $cat_id => $cat_data)
	{

		//----------------------------
		// Is this category turned on?
		//----------------------------

		if ( $cat_data['state'] != 1 )
		{
			continue;
		}
		if($ecook[$cat_id][0]!=$cat_id) 
		{
			$tmpa = array('contract_on'=>'none',
						  'expanded_on'=>'show',
						 );
			$cook []= "$cat_id.1";
		}
		else 
		{
			$tmpa = array(
							'contract_on'=>($ecook[$cat_id][1]==1 ? 'none':'show'),
							'expanded_on'=>($ecook[$cat_id][1]==1 ? 'show':'none'),
						 );
			$cook []= implode(".",$ecook[$cat_id]);
		}
		foreach ($this->forums as $forum_id => $forum_data)
		{
			if ($forum_data['category'] == $cat_id)
			{
				//-----------------------------------
				// We store the HTML in a temp var so
				// we can make sure we have cats for
				// this forum, or hidden forums with a 
				// cat will show the cat strip - we don't
				// want that, no - we don't.
				//-----------------------------------

				$temp_html .= $this->process_forum($forum_id, $forum_data);
			}
		}

		if ($temp_html != "")
		{
			$this->output .= $this->html->CatHeader_Expanded($cat_data+$tmpa);
			$this->output .= $temp_html;
			$this->output .= $this->html->end_this_cat();
		}

		unset($temp_html);
	}
	$std->my_setcookie('boardlayout',implode(",",$cook));
	$this->output .= $this->html->end_all_cats();
}

Find (Added in 1.01)

$this->output .= $this->html->CatHeader_Expanded($cat_data);

Replace with

$this->output .= $this->html->CatHeader_Expanded($cat_data+array('contract_on'=>'none','expanded_on'=>'show'));

Close & Save

 

Вообщем хотелось бы и для статистики иметь функцию сворачивания. :D

Ссылка на комментарий
Поделиться на других сайтах

Что значит "перенёс бы"? Тему можно перенести в другой раздел, а не в другую тему.
Ссылка на комментарий
Поделиться на других сайтах

Нет. Нужно найти тему поддержки модификации "мод для скрытия категорий" и задать вопрос в ту тему.
Ссылка на комментарий
Поделиться на других сайтах

Присоединиться к обсуждению

Вы можете ответить сейчас, а зарегистрироваться позже. Если у вас уже есть аккаунт, войдите, чтобы ответить от своего имени.

Гость
Ответить в этой теме...

×   Вы вставили отформатированный текст.   Удалить форматирование

  Допустимо не более 75 смайлов.

×   Ваша ссылка была автоматически заменена на медиа-контент.   Отображать как ссылку

×   Ваши публикации восстановлены.   Очистить редактор

×   Вы не можете вставить изображения напрямую. Загрузите или вставьте изображения по ссылке.

Зарузка...
×
×
  • Создать...

Важная информация

Находясь на нашем сайте, вы соглашаетесь на использование файлов cookie, а также с нашим положением о конфиденциальности Политика конфиденциальности и пользовательским соглашением Условия использования.