Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Portal_announcement
Verilog Offline
Member
***
Posts: 50
Joined: Nov 2013
Post: #4
RE: Portal_announcement
Hey RateU,
Thanks for your suggestion, I managed to get it to work. Now I wanted to know if I had two different XThreads based forums and I wanted both of them on the portal in separate sections. One option is to copy the below code and replicate it with replacing templates but that feels loading extra SQL query again. Is there a way I can get different templates so that I can display them in their own style on the portal?

Here is the code if anyone needs finds this thread Smile

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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
$bonthreads = '';
    $altbg = alt_trow();
    $bonlist = '';
    $fid = '10';
    
 		$threadfield_cache = xthreads_gettfcache($fid);
		if(!empty($threadfield_cache)){
			$xtfields = '';
			foreach($threadfield_cache as &$tf){
				$xtfields .= ', tf.'.$tf['field'].' AS xthreads_'.$tf['field'];
			}
		}

    $query = $db->query("
        SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, t.replies, t.views, u.username $xtfields
        FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."threadfields_data tf ON (tf.tid = t.tid)
        LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
        WHERE fid=10 AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
        ORDER BY t.lastpost DESC
        LIMIT 0, 10"
    );
    while($thread = $db->fetch_array($query))
    {
        $lastpostdate = my_date('relative', $thread['lastpost']);
        if(!$thread['lastposteruid'] && !$thread['lastposter'])
        {
            $lastposter = htmlspecialchars_uni($lang->guest);
        }
        else
        {
            $lastposter = htmlspecialchars_uni($thread['lastposter']);
        }
        $thread['replies'] = my_number_format($thread['replies']);
        $thread['views'] = my_number_format($thread['views']);
 
        // Don't link to guest's profiles (they have no profile).
        if($thread['lastposteruid'] == 0)
        {
            $lastposterlink = $lastposter;
        }
        else
        {
            $lastposterlink = build_profile_link($lastposter, $thread['lastposteruid']);
        }
 
        $thread['subject'] = $thread['fullsubject'] = $parser->parse_badwords($thread['subject']);
        if(my_strlen($thread['subject']) > 25)
        {
            $thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
        }
        $thread['subject'] = htmlspecialchars_uni($thread['subject']);
        $thread['fullsubject'] = htmlspecialchars_uni($thread['fullsubject']);
 
        $thread['threadlink'] = get_thread_link($thread['tid']);
        $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
        $thread['forumlink'] = get_forum_link($thread['fid']);
        $thread['forumname'] = $forum_cache[$thread['fid']]['name'];

        $threadfields = array();
        foreach($threadfield_cache as $k => &$v) {
            xthreads_get_xta_cache($v,$tids);
            $threadfields[$k] =& $thread['xthreads_'.$k];
            xthreads_sanitize_disp($threadfields[$k],$v,(!xthreads_empty($thread['username']) ? $thread['username'] : $thread['threadusername']));
        }

        eval("\$bonlist .= \"".$templates->get("portal_bonthreads_thread")."\";");
        $altbg = alt_trow();
    }
    if($bonlist)
    {
        eval("\$bonthreads = \"".$templates->get("portal_bonthreads")."\";");

    }

06-07-2020 02:07 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Portal_announcement - Verilog - 06-02-2020, 04:42 PM
RE: Portal_announcement - RateU - 06-03-2020, 03:38 AM
RE: Portal_announcement - Verilog - 06-03-2020, 04:17 PM
RE: Portal_announcement - Verilog - 06-07-2020 02:07 AM
RE: Portal_announcement - RateU - 06-07-2020, 03:46 AM
RE: Portal_announcement - Verilog - 06-07-2020, 04:51 PM
RE: Portal_announcement - RateU - 06-08-2020, 02:58 AM
RE: Portal_announcement - Verilog - 06-08-2020, 07:23 PM
RE: Portal_announcement - RateU - 06-09-2020, 01:41 AM
RE: Portal_announcement - Verilog - 06-09-2020, 06:01 PM

 Standard Tools
Forum Jump: