Hello, I'm trying to rewrite existing web with phalcon, with major ups and minor downs so far :) But there is one thing I am not able to do so far, any tries were unsuccessfull. I need in a class (in folder libraries), that gets used in phalcon controller, to use a partial renderer. In basic, im replacing BBCODE tags with their HTML representation and I do not know where in the resulting HTML the partial code will appear, so I need to render the partial into a variable and put this variable into final template. I'd like to see a minimalistic code that is needed to achive that. So far I tried (highly reduced and pseudocoded just to show the main idea) :
#controllers/TopicController.php
class TopicController extends Phalcon\Mvc\Controller
{
public function indexAction()
{
$final_html = BBClass::parse($bbcode_to_be_parsed);
}
}
#libraries/BBClass.php
class BBClass.php
{
public function parse($bbcode)
{
if (has_tag($bbcode, '[table]'))
{
$viewnew = new Phalcon\Mvc\View();
$viewnew->setViewsDir(__DIR__ . '/../views/');
$viewnew->start();
$viewnew->partial("shared/bb/table", array('some_content' => $some_content));
$viewnew->finish();
$bbcode_table = $viewnew->getContent();
//$bbcode_table is empty, no parsing occured :(
// or, i tried this
$this->view = $di->get('view');
echo $this->view->partial("shared/bb/table", array('some_content' => $some_content));
//only the partial template is shown in the browser, but not the main template and rest of the HTML
}
}
}
there are both shared/bb/table.phtml and shared/bb/table.volt templates, in the second case, the volt template is used, as I'm using volt as main template engine in the whole app, but obviously, I'm doing it wrong. I even tried the getRender method mentioned here
https://github.com/phalcon/cphalcon/issues/543
but no luck, I still get either the partial code only (and not the whole page plus partial) or whole page only and empty partial :(
Can you please help me with this ?