Hello...
I am trying to use this code:
$site_template->register_vars(array(
"news_id" => $news_id,
"news_time" => substr($news_row['news_date'], 11),
"news_date" => substr($news_row['news_date'], 0, 10),
"comments_count" => isset($comment_count['count']) ? intval($comment_count['count']) : 0,
"news_views" => ($user_info['user_level'] != ADMIN) ? $news_row['news_views']+1 : $news_row['news_views'],
"news_title" => $news_row['news_title'],
"author_name" => "<a href=\"member.php?action=showprofile&user_id=".$news_row['user_id']."\">".$author['user_name']."</a>",
"author_avatar" => $author['user_avatar'],
"news_text" => $bb->parse($news_row['news_text'])
));
$content = $site_template->parse_template("news_show");
$leave_comment_box = "test";
if($user_info['user_level'] > GUEST){
//Can leave comments
$leave_comment_box = $site_template->parse_template("news_comment_box");
}
else{
//Guests cannot leave comments on news
$leave_comment_box = 'Only registered users can post comments<br /><a href="register.php">Register here</a>';
}
$site_template->register_vars(array(
"comment_box" => $leave_comment_box));
As you can see, I call $site_template->parse_template() twice in that section.
The main template is the place holder for all news-type pages.
Inside that page, the content changes depending on the action being performed: (view all news, view a single news, post a comment, edit a comment...)
The third template comes into play when a user is viewing a single news and the user is a registered member of the site.
In this case, I want to show a COMMENT BOX where they can leave a comment, if the user is not registered a little message appears saying they need to register to leave comments...
If I add my comment box html code using a string $comment_box = "<table .......................</table>" everything is fine, but I wanted to save that in a template so it is easier to modify.
The portion that is failing is the second call to parse_template... it is being called but it is returning an empty string... when it should be parsing a file I have created...
The third called to parse_template is at the end of the file: $site_template->print_template($site_template->parse_template($main_template)); and it is the normal call to print the file.
The file is correctly created, it exists and is placed inside the template directory.
Any suggestions??
Thanks