Помогите, пожалуйста.
Делаю домашнюю страничку.
В модуле прописываю функцию, которая выводит блоки категорий и подкатегорий к данной категории.
function homepage_category() {
$content = '';
$vid = 9;
$res = db_query('SELECT tt.name, tt.tid
FROM {term_data} tt
LEFT JOIN {term_hierarchy} th
ON tt.tid = th.tid
WHERE vid = %d AND th.parent = %d', $vid,0);
if(!$res) return drupal_not_found();
while($title = db_fetch_object($res)) {
$ttid = $title->tid;
$tname = $title->name;
$content['main']['tname'][] = $tname;
$content['main']['ttid'][] = $ttid;
$sql='SELECT td.name, td.tid
FROM {term_data} td
LEFT JOIN {term_hierarchy} th
ON td.tid = th.tid
WHERE td.vid = %d AND th.parent = %d';
$res1 = db_query($sql,$vid,$title->tid);
if(!$res1) return drupal_not_found();
while($sub_title = db_fetch_object($res1)){
$sub_t = $sub_title->tid;
$sub_n = $sub_title->name;
$content['sub']['sub_t'][] = $sub_t;
$content['sub']['sub_n'][] = $sub_n;
}
}
//$content = theme(homepage_ann,$content);
return !empty($content) ? $content : 'Переменные';
}
$content = '';
$vid = 9;
$res = db_query('SELECT tt.name, tt.tid
FROM {term_data} tt
LEFT JOIN {term_hierarchy} th
ON tt.tid = th.tid
WHERE vid = %d AND th.parent = %d', $vid,0);
if(!$res) return drupal_not_found();
while($title = db_fetch_object($res)) {
$ttid = $title->tid;
$tname = $title->name;
$content['main']['tname'][] = $tname;
$content['main']['ttid'][] = $ttid;
$sql='SELECT td.name, td.tid
FROM {term_data} td
LEFT JOIN {term_hierarchy} th
ON td.tid = th.tid
WHERE td.vid = %d AND th.parent = %d';
$res1 = db_query($sql,$vid,$title->tid);
if(!$res1) return drupal_not_found();
while($sub_title = db_fetch_object($res1)){
$sub_t = $sub_title->tid;
$sub_n = $sub_title->name;
$content['sub']['sub_t'][] = $sub_t;
$content['sub']['sub_n'][] = $sub_n;
}
}
//$content = theme(homepage_ann,$content);
return !empty($content) ? $content : 'Переменные';
}
Дальше делаю шаблон node-front.tpl.php
<table>
<?php $i = 0;
foreach ($content['main'] as $main){
if (!($i % 4)) print '<tr>'; ?>
<td>
<div class="category"
<div class="cat_back">
<div class="cat_cont">
<div class="subcategory">
<div class="cat_img">
<img src="/images/<?php $main['ttid'] ?>.jpeg" alt="<?php $main['tname'] ?>" />
</div>
<div class="home_title"> <?php $main['tname'] ?></div>
<?php foreach ($content['sub'] as $sub){ ?>
<div class="home_subtitle">
<nobr><a href="library/<?php $main['ttid'] ?>/<?php $sub_name['sub_t'] ?>"> <?php $sub['sub_n'] ?></a><br /></nobr>
<?php}//вывод подкатегорий ?>
<div class="home_subtitle_other"><a href="library/<?php $main['ttid'] ?>">Другие</a></div>
</div>
</div>
</div>
</div>
</div>
</td>
<?php if (!($i+1 % 4)) print '</tr>'; ?>
<?php $i++;
} //вывод категорий ?>
</table>
<?php $i = 0;
foreach ($content['main'] as $main){
if (!($i % 4)) print '<tr>'; ?>
<td>
<div class="category"
<div class="cat_back">
<div class="cat_cont">
<div class="subcategory">
<div class="cat_img">
<img src="/images/<?php $main['ttid'] ?>.jpeg" alt="<?php $main['tname'] ?>" />
</div>
<div class="home_title"> <?php $main['tname'] ?></div>
<?php foreach ($content['sub'] as $sub){ ?>
<div class="home_subtitle">
<nobr><a href="library/<?php $main['ttid'] ?>/<?php $sub_name['sub_t'] ?>"> <?php $sub['sub_n'] ?></a><br /></nobr>
<?php}//вывод подкатегорий ?>
<div class="home_subtitle_other"><a href="library/<?php $main['ttid'] ?>">Другие</a></div>
</div>
</div>
</div>
</div>
</div>
</td>
<?php if (!($i+1 % 4)) print '</tr>'; ?>
<?php $i++;
} //вывод категорий ?>
</table>
Шаблон не выводится.
Если делать через theme, то все получается.