Posts: 6
Threads: 3
Joined: Apr 2012
Has anyone managed to pass the php commentics code to a smarty tpl file successfully?
I tried it as a php function, php code inside tpl, etc. but couldnt get it to work.
Please post your code here if you managed to do it.
Thanks
Posts: 8
Threads: 3
Joined: Aug 2012
Hey.
Yes, I solved this. Here's the method:
Assuming
$smarty is your Smarty object.
1) Get the comments html-code
Code:
// Start the output buffer
ob_start();
// Commentics configuration
$cmtx_page_id = "pageid";
$cmtx_reference = "Page title";
$cmtx_path = "/path/to/your/commentics/root/";
define ('IN_COMMENTICS', 'true');
// Call commentics
require $cmtx_path . "includes/commentics.php";
// Grab code from the output buffer
$comments_html = ob_get_clean();
2) Put the html into your smarty template object
Code:
// Assign code to a template variable
$smarty->assign("comments_html",$comments_html);
3) Display it somewhere in your template files
Posts: 14
Threads: 4
Joined: Jun 2012
Could you give a little more detail as to how you implement in the smarty folder structure, i get part 3) but where does the rest of the code go? do you make a function or something?