[Ask] Custom Front Page
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #13
RE: [Ask] Custom Front Page
(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:
1
2
3
4
5
6
7
8
9
10
11
$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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<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



Attached File(s)
.php  mn_functions_tp_load.php (Size: 4.12 KB / Downloads: 403)

(This post was last modified: 04-22-2012 04:51 AM by RateU.)
04-12-2012 08:08 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
[Ask] Custom Front Page - lenkbreak - 04-09-2012, 05:37 PM
RE: [Ask] Custom Front Page - ZiNgA BuRgA - 04-09-2012, 05:56 PM
RE: [Ask] Custom Front Page - lenkbreak - 04-09-2012, 06:39 PM
RE: [Ask] Custom Front Page - adisp007 - 04-10-2012, 03:12 AM
RE: [Ask] Custom Front Page - RateU - 04-10-2012, 06:52 AM
RE: [Ask] Custom Front Page - lenkbreak - 04-10-2012, 12:55 PM
RE: [Ask] Custom Front Page - RateU - 04-11-2012, 02:34 AM
RE: [Ask] Custom Front Page - adisp007 - 04-11-2012, 03:09 AM
RE: [Ask] Custom Front Page - RateU - 04-11-2012, 06:03 AM
RE: [Ask] Custom Front Page - lenkbreak - 04-11-2012, 11:50 AM
RE: [Ask] Custom Front Page - lenkbreak - 04-11-2012, 12:30 PM
RE: [Ask] Custom Front Page - leefish - 04-11-2012, 12:58 PM
RE: [Ask] Custom Front Page - RateU - 04-12-2012 08:08 AM
RE: [Ask] Custom Front Page - lenkbreak - 04-12-2012, 12:32 PM
RE: [Ask] Custom Front Page - lenkbreak - 04-12-2012, 05:41 PM
RE: [Ask] Custom Front Page - adisp007 - 04-12-2012, 08:20 PM
RE: [Ask] Custom Front Page - lenkbreak - 04-13-2012, 12:11 PM
RE: [Ask] Custom Front Page - RateU - 04-16-2012, 01:56 AM
RE: [Ask] Custom Front Page - lenkbreak - 04-20-2012, 02:52 PM
RE: [Ask] Custom Front Page - RateU - 04-22-2012, 05:02 AM
RE: [Ask] Custom Front Page - lenkbreak - 04-22-2012, 06:12 PM

 Standard Tools
Forum Jump: