<style>
.card-columns {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
-webkit-column-gap: 1.25rem;
-moz-column-gap: 1.25rem;
column-gap: 1.25rem;
}
.card {
display: inline-block;
width: 100%;
margin-bottom: .75rem;
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
background-color: #fff;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
break-inside: avoid-column;
}
</style>
<h3 class='text-light m-b-50'>{%custom_title%}</h3>
<div class='card-columns'>
{forum_block.{ {%container_block%} }}
</div>
<div class='card'>
<div class='list-group-item' style='min-height:250px; border-color: transparent; padding: 10px 20px; border-radius: 8px !important;'>
<div class='display-block'>
<div class='display-block center-x spacer-xs'><img src='{%forum_image_src%}' class='icon'></div>
<h3 class='text-dark'>{%forum_name%}</h3>
<div class='text-left'>{%forum_description%}</div>
</div>
<div><ul class='block'>
{subforums_block.{
<li>
<h4>
<a href='{%forum_link%}'>{%forum_title%}</a>
</h4>
<div class='text-left'>{%forum_description%}</div>
</li>
}}
</ul>
</div>
</div>
</div>
Quote
1. getInstance( $template_id );
This is a static method. The $template_id is a unique name that is given to the instance so it will not conflict with another. By instancing the template engine, it minimize system resource consumption and ensure it is very fast.
Quote
2. set_template( $path_to_your_html_file );
This is where you set and define which html file you want to use for this template instance. The path in $template_path is a relative one, and you can simply use BASEDIR, THEME, INCLUDES, or any path you would want. For best result, each unique instance should be bind to one single template path.
Quote
3. set_tag(string string $tag_source , string $html);
If you have only 1 single replacement element in your HTML, you can simply use the Single Replacement set_tag method.
The $tag_source is the marked macro label {%tag_source%} equivalent in your HTML file.
The $html is a single string value you wish to display.
Quote
4. set_block( string $block_name, array $html);
What if you have multiple items that you want to show, then the set_block method can be used. Each set_block method call will create a duplicate of the block. If you run set_block 5 times, it will create 5 elements duplicate in your final output.
The $block_name is the block title of HTML block.
The $html array is a series of elements of a tag_source and value as described as method 3 above. This changes the values of the block elements.
Quote
5. get_output(); // returns string
Displays the Final Output string which you can print echo or bind it to another template class.
function render_forum($info) {
// Create an instance for the index page
$html = \PHPFusion\Template::getInstance('forum');
// Set the path of our forum HTML file.
$html->set_template(THEME.'custom_templates/forum.html');
//print_p($this-info['forums']); // uncomment to see the MVC data
// If we have root forum category
if (!empty($this->info['forums'][0])) {
// for each of the forum category
foreach ($this->info['forums'][0] as $forum_id => $forum_data) {
//print_p($forum_data);
// Create a Item Container html using the Forum_items.html
$item = \PHPFusion\Template::getInstance('forum_child');
$item->set_template(THEME.'custom_templates/forum_items.html');
// SIngle Replacement for the Forum Block Container, such as image, title, description
$item->set_tag('forum_image_src', FORUM."images/".$forum_data['forum_image']);
$item->set_tag('forum_name', $forum_data['forum_name']." Forum");
$item->set_tag('forum_description', $forum_data['forum_description']);
// Check if there are any sub forums for this category
if ($forum_data['child']) {
foreach ($forum_data['child'] as $child_id => $child_data) {
// Use the set_block method to duplicate
$item->set_block('subforums_block',
array(
'forum_link' => $child_data['forum_link']['link'],
'forum_description' => $child_data['forum_description'],
'forum_title' => $child_data['forum_name']
)
);
}
}
// Finally, from the $item->get_output(); we have the child, and use a duplicator set_block to create container of the same in the master index file.
$html->set_block('forum_block', array(
'container_block' => $item->get_output()
)
);
}
}
// Finally display the entire html template.
echo $html->get_output();
}
Category Forum
Model View Templates - 9Labels
None yet
Statistics
3 participants
Notifications
You are not receiving notifications from this thread.
Related Questions