Recent Topics

1 Jul 12, 2011 07:35    

My b2evolution Version: Not Entered

Is there a way to display a message when a Deprecated page or post is requested?

Hoping I could have an option to redirect like /?disp=deprecated which will give the user a message on page/post request. Currently the page simply gives invalid request. :-/

2 Jul 12, 2011 08:41

Open the file /inc/items/_item.funcs.php and edit as follows

if( $disp == 'page' )
{	// Get  pages:
	$MainList->set_default_filters( array(
			'types' => '1000',		// pages
			// 'types' => '1000,1500,1520,1530,1570',		// pages and intros (intros should normally never be called)
		) );
}
elseif( $disp == 'single' )
{
	$MainList->set_default_filters( array(
			'visibility_array' => array( 'published', 'protected', 'private', 'deprecated' ),  // We added 'deprecated' to the array
		) );
}

Then edit your skin file index.main.php or single.main.php (if you have it) and add this right after skin_init( $disp );

// This is the main template; it may be used to display very different things.
// Do inits depending on current $disp:
skin_init( $disp );

if( $disp == 'single' && !empty($Item) )
{
	if( $Item->status == 'deprecated' )
	{
		// Print some message
		$Messages->add( sprintf('The item is deprecated: %s', $Item->title), 'note');
		
		// Hide the item
		$GLOBALS['MainList'] = NULL;
		
		$disp = 'my_custom_disp'; // optionally display some custom page
	}
}

3 Jul 12, 2011 22:53

didn't work for me, ): probably because how I designed my skin, but I ended up writing a function in _skin.class.php which resolved it. Thanks.


Form is loading...