Forums and Subforums on the subpage.
#11
Can't tell more without seeing the complete code you're using (with templates' content). Also, what's the result of var_dump($subforums); after the while loop?
Reply
#12
Code in file basically is no different. In template there is no aesthetic appearance, I mainly depends on the action of the moment.
Template parent:
<div class="col"><strong><a href="{$forum_url}">{$forum['name']}</a></strong> <br />{$subfora}</div>
Template child - only forum name.
Destroy666 Wrote:Also, what's the result of var_dump($subforums); after the while loop?

Returns array forums + subforums.
array(2) { [4]=> string(210) "
SubForum1
SubForum2
" [2]=> string(108) "
Subforum3
" }

Reply
#13
It seems to me that simply can not read variable $subfora in the template. The source of the page is blank.

<?php

define('IN_MYBB', 1); 
define('THIS_SCRIPT', 'myfile.php');
require_once './global.php';
require_once MYBB_ROOT.'inc/functions_forumlist.php';
require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new postParser;

add_breadcrumb("Nazwa nowej podstrony", "myfile.php"); //Nazwa w nawigacji



$query = $db->query("
    SELECT *
    FROM {$db->table_prefix}forums
    WHERE active != 0 AND fid IN(4,2,5,3,8) OR pid IN(4,2,5,3,8)
    ORDER BY FIELD(pid,2,3,4,5,6,8), disporder
");


$subforums = array();

while($forum = $db->fetch_array($query))
{
	
	$forum_url = get_forum_link($forum['fid']);
    // sprawdzasz czy forum jest "dzieckiem" jednego z "rodziców" 1,4,5 czy jakie tam masz te główne fora
    if(in_array($forum['pid'], array(4,2))) {
        // przypisujesz szablony "dzieci" do indeksu danego forum "rodzica" - w szablonie używasz np. $forum['name'] i cokolwiek chcesz
        eval('$subforums[$forum["pid"]] .= "'.$templates->get('dld_subforums').'";');
	}
    else
    {
       // w przeciwnym wypadku mamy forum "rodzica" - zapisujesz jego "dzieci" do prostszej zmiennej
       $subfora = '';
		if(isset($subforums[$forum['fid']])) 
           $subfora = $subforums[$forum['fid']];			
		// wyświetlasz $subfora, $forum['name'] i co tam chcesz w szablonie "rodzica"		
		eval('$dzialy .= "'.$templates->get('dld_fora').'";');
	}	        
} 

//var_dump($subforums);

eval('$forum1 = "'.$templates->get('dl').'";');
output_page($forum1); 


Reply
#14
1. You're using different forums in IN, FIELD and in_array() check, they should be consistent.
2. Try changing:
ORDER BY FIELD(pid,2,3,4,5,6,8), disporder
to:
ORDER BY FIELD(pid,4,2,5,3,8) DESC, disporder
and it should work: http://nooo.hol.es/mybb16/testforums.php
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)