Recent Topics

1 Jul 04, 2007 21:03    

My b2evolution Version: Not Entered

How can I do it? I need a generic hack to only show the categories of BlogAll in the main page; but I need that although I make new blogs (new id´s) their cats are hidden only in blogall (so I think it will be a hack for the blogall theme).

Thanks.

2 Jul 05, 2007 04:25

You should be able to figure it out, hack applies in index.php

# Additionnaly, you can set other values (see URL params in the manual)...
# $order = 'ASC'; // This for example would display the blog in chronological order...

# Customized Categories
$custom_categories = array(
// blog	=>	array of categories you want to use
	1	=>	array(1,2,3,4,5,6)
);
if
(	// Pre-Reqs for our customized display
	isset($custom_categories[$blog])/* do we have custom categories for the current blog? */
	&& !isset($_REQUEST['disp'])	/* altern display */
	&& !isset($_REQUEST['m'])		/* archives */
	&& !isset($_REQUEST['s'])		/* search */
	&& !isset($_REQUEST['more'])	/* single post */
	&& !isset($_REQUEST['cat'])		/* categories */
	&& !isset($_REQUEST['catsel[]'])/* categories */
)
{	# Apply our custom categories
	$catsel = $custom_categories[$blog];
	$cat = implode(',', $catsel);
}
unset($custom_categories);

// That's it, now let b2evolution do the rest! :)
require $inc_path.'_blog_main.inc.php';

3 Jul 05, 2007 10:20


# We have custom categories
$custom_cats = array(
//    blog    =>    cats
    1        =>    '1,26,34,61,60,59,65,68,77,85,92',
	2        =>    '1',
	3        =>    '26',
	4        =>    '34',
	5        =>    '61',
	6        =>    '60',
	7        =>    '59',
	8        =>    '65',
	9        =>    '68',
	10        =>    '77',
	11        =>    '85',
	12        =>    '92',
);
if ( isset($custom_cats[$blog]) &&
!isset($_REQUEST['s']) /* search */ &&
!isset($_REQUEST['more']) /* single */ &&
!isset($_REQUEST['m']) /* date */ &&
!isset($_REQUEST['disp']) /* disp */ &&
!isset($_REQUEST['cat']) &&
!isset($_REQUEST['catsel'])
)
{    // We have custom cats for this blog
    $cat = $custom_cats[$blog];
    $catsel = explode(',', $cat);
}
unset($custom_cats);

// That's it, now let b2evolution do the rest! :)
require $inc_path.'_blog_main.inc.php'; 

This is the code to show in each blog only the post from the cats chosen. Only blogAll can have cats from others blogs (For example if you put a cat from blog 2 in blog 3 th cats will not be showed). With this code only show in the main page the post of, for example, a news cat in each blog.

But If you use BlogAll like Main Page, all the cats from others blog will be showed in the sidebar, so, how can I hide them? (Only hide in main page but if you want you can go to their current blog and access to their. I don´t want to edit index.php every time I make a new blog, so I must be a generic hack in the sidebar like IF BLOG = 1 show EVERY CATS if not hide them.

Thanks indeed and sorry about my english

4 Jul 05, 2007 19:02

I answered your question before the crash didn't I, that's why you have that code... Deja vu' anyone?

5 Jul 05, 2007 22:33

Yeahhh I know it, you put it, but as the post was removed I put again you put in that moment. Thanks.

6 Jul 25, 2007 11:39

Sorry but, How can I make it generic? That is every time I make a new blog I must put the Cat, but if ever it is the same name of cat like "news" can I make a generic search (with a select for example) and not to write de index.php?

Thanks again.

7 Jul 25, 2007 12:26

This could work

# Additionnaly, you can set other values (see URL params in the manual)...
# $order = 'ASC'; // This for example would display the blog in chronological order...

# Customized Categories
// Manual categories
$custom_categories = array(
// blog    =>    array of categories you want to use
    1    =>    array(1,2,3,4,5,6)
);

// Generic categories
$generic_categories = array();
$mysql_result = mysql_query('SELECT `cat_ID` FROM `evo_categories` WHERE `cat_name` = \'News\'');
if ( $mysql_error = mysql_error() ) die($mysql_error);
for ( $row = 0, $rows = mysql_num_rows($mysql_result); $row < $rows; ++$row )
	$generic_categories[] = mysql_result($mysql_result, $row, 'cat_ID');
$custom_categories[$blog] = $generic_categories;

// Apply
if
(    // Pre-Reqs for our customized display
    isset($custom_categories[$blog])/* do we have custom categories for the current blog? */
    && !isset($_REQUEST['disp'])    /* altern display */
    && !isset($_REQUEST['m'])        /* archives */
    && !isset($_REQUEST['s'])        /* search */
    && !isset($_REQUEST['more'])    /* single post */
    && !isset($_REQUEST['cat'])        /* categories */
    && !isset($_REQUEST['catsel[]'])/* categories */
)
{    # Apply our custom categories
    $catsel = $custom_categories[$blog];
    $cat = implode(',', $catsel);
}
unset($custom_categories);

// That's it, now let b2evolution do the rest! :)
require $inc_path.'_blog_main.inc.php'; 

8 Jul 25, 2007 18:01

You are my hero, thanks I´m goint to try it

9 Jul 27, 2007 19:21

ohh It doesn´t work. I ´ll try to revise it

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\work\workspace\web\irica\web\index.php on line 129

Warning: Cannot modify header information - headers already sent by (output started at D:\work\workspace\web\irica\web\index.php:129) in D:\work\workspace\web\irica\web\inc\MODEL\skins\_skin.funcs.php on line 71

10 Jul 27, 2007 19:53

whoops, updated previous post, try again :)

11 Jul 28, 2007 00:10

It doesn´t work yet. The problem is with mysql_num_rows...

12 Sep 17, 2007 05:53

Any solution? Thank you indeed.


Form is loading...