MyBB Hacks

Full Version: [Ask] Custom Front Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
@adisp007 and @rateu
I forgot to ask you something
can you give me some suggestions for me?

I made index.php file and use it as my index forum at http://lenkbreak.host56.com/
and I made a new template in global template.

I doing that because Page Manager confusing me a lot.
so, I've been trying adisp007 suggestion and this is the page http://lenkbreak.host56.com/forum/misc.php?page=test

the questions :
1. How can I make a page without using Page Manager like I made before for http://lenkbreak.host56.com/ ?
The confusing part is, how to separate that php codes and html codes? I mean, in a new page i have to put php codes and in global template i have to put html codes, do i just separate those codes and just paste it? or can I use PHP in template plugin so i can make a new template with php code inside directly?

2. If you see in http://lenkbreak.host56.com/forum/misc.php?page=test I tried to make one thread with long title and it mess up other table. Can you give me step how to limit the character to be show?

slowly I learn much about html and php from codes above. Smile
Hello, I found this post and the accompanying files from Tomm at Xekko to be very useful when making my first custom page.

http://resources.xekko.co.uk/thread-98-p...http://resources.xekko.co.uk/thread-98-post-875.h
(04-11-2012 11:50 AM)lenkbreak Wrote: [ -> ]you know what? this is what I like from community like this!!
people like you and adisp007 share their knowledge with noobs like me and never ask to be pay
Who said that you don't need to pay?
I don't know about adisp007, but yo need to pay me about US$1mil for each question.
Hmmmmm..... I need to count how many questions you've asked.....
Trust me, it's better than Yumi/ZiNgA's rate:
http://endlessparadigm.com/forum/showthr...http://endlessparadigm.com/forum/showthread.php?tid=18

(04-11-2012 12:30 PM)lenkbreak Wrote: [ -> ]@adisp007 and @rateu
I forgot to ask you something
can you give me some suggestions for me?
Another US$1mill. Yes!!!

(04-11-2012 12:30 PM)lenkbreak Wrote: [ -> ]the questions :
1. How can I make a page without using Page Manager like I made before for http://lenkbreak.host56.com/ ?
The confusing part is, how to separate that php codes and html codes? I mean, in a new page i have to put php codes and in global template i have to put html codes, do i just separate those codes and just paste it? or can I use PHP in template plugin so i can make a new template with php code inside directly?

2. If you see in http://lenkbreak.host56.com/forum/misc.php?page=test I tried to make one thread with long title and it mess up other table. Can you give me step how to limit the character to be show?

You can try to use this function (attached).
Upload the file to your forum dir. You can place it at the same folder with your custom index.
Include the file to your custom index, and try to use the function to load the latest threads/posts or the most viewed/replies threads from a specified forums.

The settings is like this:

PHP Code:
$latest_threads_options = array(
	'type' => 'threads',// available options: threads or posts
	'limit' => 5,// how many threads/posts should be displayed
	'order_by' => 'dateline',// available options: dateline, views or replies
	'order_dir' => 'desc',// available options: asc or desc
	'fids' => '1,2',// from which forum(s) the threads/posts should be pulled out
	'fids_format' => 'IN',// available options: IN or NOT IN
	'childtemplate' => 'latest_threads_thread',// template and variable name for each data in Global Template. List this template in the $templatelist to cache it
	'maintemplate' => 'latest_threads',// template name for holding all of the data in Global Template. List this template in the $templatelist to cache it.
	'maxchars' => 30// Max chars for the thread/post title should be displayed
);

Then, you can call it like this (in your custom page code):

PHP Code:
$latest_threads = mn_tp_load($latest_threads_options);

Put the {$latest_threads} variable in your custom index template in the Global Template.

For example:
In this example, it is in the same location with your custom index file:

PHP Code:
<?php
define('IN_MYBB',1);
define('THIS_SCRIPT','myindex.php');
$templatelist = 'example,latest_threads_thread,latest_threads,latest_posts,latest_posts_post,hot_threads,hot_threads_thread,popular_threads,popular_threads_thread';
require_once './forum/global.php';
require_once './mn_functions_tp_load.php';
// Displaying 5 latest threads from forum id 2 and 3
$latest_threads_options = array(
	'type' => 'threads',
	'limit' => 5,
	'order_by' => 'dateline',
	'order_dir' => 'desc',
	'fids' => '2,3',
	'childtemplate' => 'latest_threads_thread',
	'maintemplate' => 'latest_threads',
	'maxchars' => 25
);
$latest_threads = mn_tp_load($latest_threads_options);
// Displaying 5 latest posts from forum id 3,4,5
$latest_posts_options = array(
	'type' => 'posts',
	'limit' => 5,
	'order_by' => 'dateline',
	'order_dir' => 'desc',
	'fids' => '3,4,5',
	'childtemplate' => 'latest_posts_post',
	'maintemplate' => 'latest_posts',
	'maxchars' => 30
);
$latest_posts = mn_tp_load($latest_posts_options);
// Displaying 8 most replied threads from forum id 5
$hot_threads_options = array(
	'type' => 'threads',
	'limit' => 8,
	'order_by' => 'replies',
	'order_dir' => 'desc',
	'fids' => 5,
	'childtemplate' => 'hot_threads_thread',
	'maintemplate' => 'hot_threads',
	'maxchars' => 25
);
$hot_threads = mn_tp_load($hot_threads_options);
// Displaying 8 most viewed threads from forum id 6,7
$popular_threads_options = array(
	'type' => 'threads',
	'limit' => 8,
	'order_by' => 'views',
	'order_dir' => 'desc',
	'fids' => '6,7',
	'childtemplate' => 'popular_threads_thread',
	'maintemplate' => 'popular_threads',
	'maxchars' => 25
);
$popular_threads = mn_tp_load($popular_threads_options);
eval('$example .= "'.$templates->get('example').'";');
output_page($example);
?>

Put {$latest_threads}, {$latest_posts}, {$hot_threads} and {$popular_threads} variable in your custom index template (maybe you need to design it):

HTML Code
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
{$latest_threads}
{$latest_posts}
{$hot_threads}
{$popular_threads}
<br style="clear: both" />
{$footer}
</body>
</html>

Then design your latest_threads, latest_threads_thread template:
latest_threads template (for example only):

HTML Code
<div class="float_right tborder trow1" style="width:33%">
	<div class="thead" style="padding:{$theme['tablespace']}px;text-align:center"><strong>New Topics</strong></div>
	{$latest_threads_thread}
</div>

Note that the {$latest_threads_thread} variable calls the latest_threads_thread template (the child template for the Latest Threads block). The template hold each latest thread data:
latest_threads_thread template (for example only):

HTML Code
<div class="clear smalltext" style="padding:{$theme['tablespace']}px">
	<span class="float_right">{$data['author']}, {$data['tpdate']}</span>
	<span>{$data['tplink']}</span>
</div>

Data array you can use in this template:
{$data['tplink']} : thread/post subject (linked)
{$data['author']} : thread/post author's username (linked)
{$data['tpdate']} : thread/post date submitted
{$data['tptime']} : thread/post date submitted
{$data['views']} : thread/post views
{$data['replies']} : thread/post replies

Do the template edit with the other blocks too.

Here is a simple example for that:
http://www.mynie.co.cc/example.php

O MY GOD..!!!
$1mil for each questions? can I pay just $1 for down payment? Tongue

I don't know what to say..
you give me steps for what I'm looking for
Thanks thanks thanks a lot!!!
maybe if you here beside me, I will hug n kiss you

once again thanks for your help RateU
More question for RateU (I hope this is not another $1mil Tongue)

From scripts you above, I can make a table with new threads from specify forum. But how can I make 2 or more table with new threads from specify forum?

I'm tried make this function and put it in my custom page

PHP Code:
// Displaying 5 latest threads from forum id 11
$latest_threads_othersports_options = array(
	'type' => 'threads',
	'limit' => 5,
	'order_by' => 'dateline',
	'order_dir' => 'desc',
	'fids' => '11',
	'childtemplate' => 'latest_threads_thread_othersports',
	'maintemplate' => 'latest_thread_othersports',
	'maxchars' => 25
);
$latest_threads_othersports = mn_tp_load($latest_threads_othersports_options);


and insert new variable in templatelist like this

PHP Code:
$templatelist = 'page,latest_threads_thread,latest_threads,latest_threads_thread_othersports,latest_threads_othersports,latest_posts,latest_posts_post,hot_threads,hot_threads_thread,popular_threads,popular_threads_thread';


after that i made new template in global template and named it latest_threads_othersports and latest_threads_thread_othersports

after that i put the variable in my custom php page so it look like this :

PHP Code:
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
{$latest_posts}
{$latest_threads}
{$latest_threads_othersports}
{$hot_threads}
{$popular_threads}
<br style="clear: both" />
{$footer}
</body>
</html>


but after i tried to open that page on my browser, i did not see my new table from my specify forum.

did i do something wrong? need your suggestions Smile

this is my custom page http://lenkbreak.host56.com/default.php

Typo.
threads , not thread.

PHP Code:
'maintemplate' => 'latest_thread_othersports',

II
\/

PHP Code:
'maintemplate' => 'latest_threads_othersports',

Biggrin

Oh.. God
That's way I'm using glasses right now..
now it's work.. thanks adisp007
If you pull out some new threads from a not too active section (for example, Announcements forum), maybe it's better if you cache it.

(04-11-2012 03:09 AM)adisp007 Wrote: [ -> ]http://komunitas.mybbindonesia.com/threa...http://komunitas.mybbindonesia.com/thread-1337-post-9410.ht
It seems that the site Admin is a clown.
One more question
how to set if I want to displaying 5 latest thread from all forum?
I tried to set fids to 0 and left it blank, but it shown nothing
(04-20-2012 02:52 PM)lenkbreak Wrote: [ -> ]how to set if I want to displaying 5 latest thread from all forum?
Try the update. There is an additional settings needed to add to your array settings:

PHP Code:
'fids_format' => 'NOT IN',

Available options are: IN or NOT IN
Example:

PHP Code:
// Latest threads from all forums except forum id 2, 3 and 4
$latest_threads_options = array(
	'type' => 'threads',
	'limit' => 2,
	'order_by' => 'dateline',
	'order_dir' => 'desc',
	'fids' => '2,3,4',
	'fids_format' => 'NOT IN',
	'childtemplate' => 'latest_threads_thread',
	'maintemplate' => 'latest_threads'
);

You can use 0 as fids value. Just make sure that you don't have a forum that has a View Own Threads setting. If you have it, add the forum id(s) into the fids list, so it will be excluded from the result (if you use NOT IN in fids_format setting).

I'm really sorry for my late reply.

Pages: 1 2 3
Reference URL's