Jump to content

  • twitter
  • youtube
  • googleplus
  • facebook
  • rss
  • newsletter


Tutorial info Visit support topic

  • Added on: Jan 21 2009 04:11 AM
  • Views: 3588
 


[IPB 2.3.x] Create an IPB components location page

Posted by Michael on Jan 21 2009 04:11 AM
Instead of placing your mods location in the lang_online.php file, IPB 2.3.x offers you the ability to add a mods location without editing files.

This file should be placed in the sources/components_location/ folder and be named to reflect your component. I find it easier to name the components_public and components_location file the same.

Here is an example of an components_location file.

<?php

if ( ! defined( 'IN_IPB' ) )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. 
If you have recently upgraded, make sure you upgraded 'admin.php'.";
	exit();
}

class components_location_news
{
	var $ipsclass;
	
	function get_session_variables()
	{
		return array( '1_type' => 'news',
					  '1_id'   => $this->ipsclass->input['id'],
					);
	}
		
	function parse_online_entries( $array=array() )
	{
		$this->ipsclass->load_language( 'lang_news' );
	
		$return = array();
	
		if ( is_array( $array ) and count( $array ) )
		{
			foreach( $array as $session_id => $session_array )
			{
				$return[ $session_id ] = array_merge( $session_array, array( 
'_url' => $this->ipsclass->base_url.'autocom=news', 
'_text' => $this->ipsclass->lang['viewing_news'], '_parsed' => 1 ) );
			}
		}
		
		return $return;
	}
}
?>

You would of course change the component key news to your components key. This is a very simple example of what you can do, you also have the ability to assign a location for individual pages of your component.

You can find more examples in sources/components_location/chat_sigma.php and chat_para.php including more details on the functions within the files.

Powered by Tutorials 1.4.1 © 2012, by Michael McCune