H
H
Hey One2019-11-10 21:04:10
Smarty
Hey One, 2019-11-10 21:04:10

How to solve the template rendering problem?

The bottom line is this, there is a file with settings (setup_pages.php):

<?php

require_once 'libs/Smarty.class.php';

$smarty = new Smarty();

$smarty->template_dir = 'templates';
$smarty->compile_dir = 'templates_c';
$smarty->config_dir = 'configs';
$smarty->cache_dir = 'cache';

$sql = "SELECT * FROM posts WHERE id =".$post_id; 
$result = mysqli_query($connect, $sql); 
$separate_post = mysqli_fetch_assoc($result);

$smarty->display('templates/post.tpl');

?>

And also the template file (post.tpl)
The problem is that when opening the post.php file, the template file is not displayed, but gives an error:
Fatal error: Uncaught --> Smarty: Unable to load template 'file:templates/post. tpl' <-- thrown in D:\OpenServer\OSPanel\domains\testproject\testblog\libs\sysplugins\smarty_internal_template.php on line 195
Although the paths are correct. The settings file is located at the root, the call goes to a folder, I don’t understand why it gives an error...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question