Showing the active/current category

Download plugins, language packs and stuff.

Showing the active/current category

Postby RDM » Sat Oct 27, 2007 3:05 pm

FI-DD wrote:In inc/functions.inc.php change this:
Code: Select all
function category_get_tree($prefix = '', $tpl = '{name}', $no_prefix = true, $id = 0, $level = 0){
global $sql, $PHP_SELF;
static $johnny_left_teat;

   $level++;

   foreach ($sql->select(array('table' => 'categories', 'where' => array("parent = $id"), 'orderby' => array('id', 'ASC'))) as $row){
      $find = array('/{id}/i', '/{name}/i', '/{url}/i', '/{icon}/i', '/{template}/i', '/{prefix}/i', '/\[php\](.*?)\[\/php\]/ie');
      $repl = array($row['id'], $row['name'], $row['url'], ($row['icon'] ? '<img src="'.$row['icon'].'" alt="'.$row['icon'].'" border="0" align="absmiddle">' : ''), $row['template'], (($row['parent'] or !$no_prefix) ? $prefix : ''), '\\1');
      $johnny_left_teat .= ($no_prefix ? preg_replace('/('.$prefix.'{1})$/i', '', str_repeat($prefix, $level)) : str_repeat($prefix, $level));
      $johnny_left_teat .= preg_replace($find, $repl, $tpl);
      category_get_tree($prefix, $tpl, $no_prefix, $row['id'], $level);
   }

return $johnny_left_teat;
}


to this:
Code: Select all
function category_get_tree($prefix = '', $tpl = '{name}', $no_prefix = true, $id = 0, $level = 0){
global $sql, $PHP_SELF;
static $johnny_left_teat;

   $level++;
   $get_cat = end($blah = explode("/", $_GET['category']));

   foreach ($sql->select(array('table' => 'categories', 'where' => array("parent = $id"), 'orderby' => array('id', 'ASC'))) as $row){
      $find = array('/{id}/i', '/{name}/i', '/{url}/i', '/{icon}/i', '/{template}/i', '/{prefix}/i', '/\[php\](.*?)\[\/php\]/ie', '/{class}/i');
      $repl = array($row['id'], $row['name'], $row['url'], ($row['icon'] ? '<img src="'.$row['icon'].'" alt="'.$row['icon'].'" border="0" align="absmiddle">' : ''), $row['template'], (($row['parent'] or !$no_prefix) ? $prefix : ''), '\\1', $get_cat == $row['url'] ? 'active' : 'nonactive');
      $johnny_left_teat .= ($no_prefix ? preg_replace('/('.$prefix.'{1})$/i', '', str_repeat($prefix, $level)) : str_repeat($prefix, $level));
      $johnny_left_teat .= preg_replace($find, $repl, $tpl);
      category_get_tree($prefix, $tpl, $no_prefix, $row['id'], $level);
   }

return $johnny_left_teat;
}


Then change this:
Code: Select all
function cn_category($prefix = '&nbsp;', $tpl = '<li><a href="[php]cute_get_link($row, category)[/php]" class="??" >{name}</a></li>', $no_prefix = true, $level = 0)


to this:
Code: Select all
function cn_category($prefix = '&nbsp;', $tpl = '<li><a href="[php]cute_get_link($row, category)[/php]" class="{class}" >{name}</a></li>', $no_prefix = true, $level = 0)


I think this is very useful and i guess a lot of people will want this. FI-DD post it in other topic. It works but we have a little problem. U need to "clear cache" everytime, before u enter into a category. Otherwise, it will show what category it in the cache.
RDM
 
Posts: 40
Joined: Fri Jan 12, 2007 9:07 pm

Postby Ramon » Sat Oct 27, 2007 4:34 pm

Try changing
Code: Select all
define('cache', true);
in head.php to
Code: Select all
define('cache', false);
Image
Ramon
 
Posts: 599
Joined: Wed Oct 12, 2005 8:51 pm
Location: Hoogeveen, NL

Postby RDM » Sun Oct 28, 2007 12:04 pm

It works.. thank you!
RDM
 
Posts: 40
Joined: Fri Jan 12, 2007 9:07 pm

Postby acateoN » Sun Apr 06, 2008 5:50 pm

Code: Select all
function cn_category($prefix = '&nbsp;', $tpl = '<li><a href="[php]cute_get_link($row, category)[/php]" class="??" >{name}</a></li>', $no_prefix = true, $level = 0)


Is that also in the functions.inc.php? I can't find it! : )
acateoN
 
Posts: 51
Joined: Tue Feb 12, 2008 10:02 pm

Postby FI-DD » Wed Apr 09, 2008 4:46 pm

No, that's in plugins/etc.php.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby acateoN » Thu Apr 10, 2008 8:36 pm

Thanks!
http://www.xpl.se - Runs under CNR
acateoN
 
Posts: 51
Joined: Tue Feb 12, 2008 10:02 pm

Postby hetes » Thu Apr 17, 2008 4:21 pm

How can i show the active category's name above my news?

for example:
Funny videos

Funny video #1
Funny video #2
Funny video #3
...

I want to show something like in the <title> if i use <?=cn_title(' &laquo; ', true); ?>...
User avatar
hetes
 
Posts: 36
Joined: Tue Apr 17, 2007 4:33 pm
Location: Hungary

Postby eberswine » Wed Mar 31, 2010 1:22 am

Has anyone fixed this hack to work correctly without turning off cache?

DarkSlim, I bet you can come up with something goooood!
User avatar
eberswine
 
Posts: 289
Joined: Thu Apr 26, 2007 7:23 pm


Return to Additional Downloads



Who is online

Users browsing this forum: No registered users and 0 guests

cron