Zaloguj się, aby obserwować  
Obserwujący 0
Spanner

[Artykuł/Tutorial] Własna strona w IP.Board 2.1.x

1 post w tym temacie

Tytuł: Własna strona w IP.Board 2.1.x

Opis:

Kategoria: IP.Board 2.1.x

Data dodania: 01.01.09, 16:30

Autor: Spanner

Artykuł pokazuje, jak stworzyć własną stronę w IP.Board, której adres będzie index.php?act=test

Otwieramy plik index.php

Znajdź:

"online" => array( "online" , 'online' , array() ),
Dodaj poniżej:
"test"	   => array( "test"			   , 'test'		 , array() ),
Tworzymy plik o nazwie: lang_test.php z następującą zawartością:
<?php
$lang = array([
'page_title' => "Moja przykładowa strona Boo!",
'navigation' => "Strona Boo",
'newmsgs' => "Nowa wiadomość",
'edit_sig' => "Edytuj sygnaturke",
'new_posts' => "Nowe Posty",
'ucp' => "<strong>Panel Usera</strong>",
'qip' => "Szybki panel informacji",
'cat_title' => "Moja strona Boo ",
'top5' => "5 ostatnich postów",
'top5_title' => "Tytuł",
'top5_last' => "Ostatnie Posty"
);
?>[/code] Plik wgrywamy do katalogu: [b]/cache/lang_cache/nazwa_langu/[/b] [b]Tworzymy plik o nazwie: test.php z zawartością:[/b]
[code]<?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 all the relevant files."; exit();

}

//First you class must be named same as your page.php in our case "boo"
//class NAMEOFYOURPAGE

class test
{

#MAIN VAR - REQUIRED ALWAYS!

var $ipsclass; //Main IPSclass class.

#---------------------------------------------------------------
#REQUIRED VARS

var $output = "";
var $html = "";

#---------------------------------------------------------------
#OTHERS - NOT REQUIRED JUST FANCY THINGY

var $page_title = "";
var $nav = array();
#---------------------------------------------------------------


/*-------------------------------------------------------------------------*/
// Auto run
// First thing IPB runs when you call this class... /*-------------------------------------------------------------------------*/

function auto_run()
{

//-----------------------------------------
// Require the HTML and language modules
//-----------------------------------------


//lang_NameofYourPage in our case boo same goes with skin_

$this->ipsclass->load_language('lang_test');
$this->ipsclass->load_template('skin_test');

//------------------------------------------------------

$this->base_url = $this->ipsclass->base_url; //nothing special just hold ur site base url in $this->base_url

#SHOW THE PAGE!
$this->show_page();
#-------------------------

//******************************************
// Ok many of you might want to have different sections in the page so how u do it ?... easily just do ur different sections (functions) then
// in your links call them boo.php?code=01 and so on... you simple put this code, instead of the above $this->show_....
//
// switch($this->ipsclass->input['CODE'])
// {
// case '01':
// $this->do_blah1();
// break;
// case '02':
// $this->do_blah2();
// break;
// default:
// $this->do_default_blah();
// break;
// }
//*********************************************

//-----------------------------------------
// PRINT HTML OUTPUT - REQUIRED
//-----------------------------------------

$this->ipsclass->print->add_output("$this->output");
$this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );

//----------------------------------------------
}

/*-------------------------------------------------------------------------*/
// Show the page!
// In 2.0 tutorial I got lazy and just showed u some how to pass current member name...
// but now we gonna retrieve 5 latests post... and do a lil member panel - QUICKIE STYLE! nothing fancy... /*-------------------------------------------------------------------------*/

function show_page()
{

#Lets build quick panel...
$mem_id = $this->ipsclass->member['id'];
#avatar
$member = $this->ipsclass->DB->build_and_exec_query(array(
'select' => 'avatar_location,avatar_size,avatar_type',
'from' => 'member_extra', 'where' => "id='$mem_id'"
));
$mem_avatar = $this->ipsclass->get_avatar( $member['avatar_location'] , 1, $member['avatar_size'], $member['avatar_type'] );
#latest posts
$this->ipsclass->DB->build_query(array(
'select' => 'tid,title,last_poster_name,last_poster_id',
'from' => 'topics',
'order' => 'pinned ASC,last_post DESC',
'limit' => array(0,5)
));
$this->ipsclass->DB->exec_query();
#format the latest posts and put them in an ugly table
$links = '<div class="borderwrap" style="width:50%">
<table class="ipbtable" cellspacing="1">
<tbody>
<tr>
<th colspan="2" width="66%">'.$this->ipsclass->lang['top5'].'</th>
</tr>
<tr>
<th width="66%">'.$this->ipsclass->lang['top5_title'].'</th>
<th width="34%">'.$this->ipsclass->lang['top5_last'].'</th>
</tr>';
while($r = $this->ipsclass->DB->fetch_row())
{
$links .= "<tr><td class=\"row1\"><a href=\"{$this->ipsclass->base_url}showtopic={$r['tid']}\">{$r['title']}</a></td>
<td class=\"row2\">by: <a href=\"{$this->ipsclass->base_url}showuser={$r['last_poster_id']}\">{$r['last_poster_name']}</td></tr>";
}
$links .= "</table></div>";

#STORE THE OUTPUT in show_page function [created at ACP] and pass your variables...
$this->output = $this->ipsclass->compiled_templates['skin_test']->show_page($mem_avatar,$links);
/*
ok see the $this->ipsclass->compiled_templates['skin_test'] -- here you select which template to store your output
which obviously will be your page template... so format is skin_yourpagename

$this->ipsclass->compiled_templates['skin_test']->show_page

where show_page is the template bit you will be creating in ACP where you would code the HTML of your page then we are passing 2 variables which we'll use in show_page template bit in ACP...
*/

// code below is obvious...
//if you dont get it plz do everyone a favor and kill urself to eliminate dummies LOL
$this->page_title = $this->ipsclass->lang['page_title'];
$this->nav = array($this->ipsclass->lang['navigation']);
}
}
?>
Plik umieszczamy w katalogu: /sources/action_public/ Otwórz cache/lang_cache/nazwa_langu/lang_online.php:
WHERE_stats => "Viewing Stats",
Wklej poniżej:
WHERE_test => "Ogląda stronę test",
Przejdź do ACP -> Look & Feel -> wybrany skin -> Edit Template HTML -> All Global HTML Zjedź na dół i kliknij na Add Template Bit i ustaw wszystko wg. poniższego schematu: New Template Bit Name: show_page New Template Bit Incoming Data Variables: $avatar="",$links="" New Template Bit Group: skin_global Or Create New Group: skin_test Kliknij Continue i następnie wklej poniższy kod do okna:
<div class="borderwrap">
<div class="maintitle">
<p><img src="http://forums.invisionize.com/style_images/1/nav_m.gif" alt=">" border="0" height="8" width="8"> {$this->ipsclass->lang['cat_title']}</p>
</div>
<table class="ipbtable" cellspacing="1">
<tbody>
<tr>
<th colspan="2" width="66%">{$this->ipsclass->lang['qip']}</th>
</tr>
<tr>
<td class="row2">
<fieldset>
<legend>Welcome {$this->ipsclass->member['members_display_name']}</legend>
<a href="{$this->ipsclass->base_url}act=UserCP&CODE=24" title="Change Avatar">{$avatar}</a>
<div style="position:relative;left:100px;top:-83px">
{$links}
</div>
</td>
</tr>
<tr>
<td class="catend" colspan="5"><!-- no content --></td>
</tr>
</tbody></table>
</div>[/code]

Od teraz strona będzie dostępna pod adresem: [b]adresStrony/index.php?act=test[/b]

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

Chcesz dodać odpowiedź ? Zaloguj się lub zarejestruj nowe konto.

Tylko zarejestrowani użytkownicy mogą komentować zawartość tej strony

Utwórz konto

Zarejestruj nowe konto, to bardzo łatwy proces!


Zarejestruj nowe konto

Zaloguj się

Posiadasz własne konto? Użyj go!


Zaloguj się
Zaloguj się, aby obserwować  
Obserwujący 0

  • Kto przegląda   0 użytkowników

    Brak zalogowanych użytkowników przeglądających tę stronę.