Render a template file from a controller

Permalink
Hello again,

I want to render a template within a controller to pass the rendered template back to the ajax caller. What is the best way to do this.

How can i load templates from a custom template folder located in my package?

In Zend Framework projects it is easy to do this. But how it goes in Concrete5?

Playing around with the "View" object failed cause either a "theme" is missing or the template path is the core view path from C5. Setting the view path with "setViewRootDirectoryName" appends my path to the view path from C5 ... frustrating.


Currently i use 5.7.4RC1 for developing my page.

elpado
 
elpado replied on at Permalink Reply
elpado
Finally I found a solution.

<?php
namespace Concrete\Package\MyPackage\Controller;
// needed modules
use Concrete\Core\Controller\Controller;
use \Concrete\Core\Http\Request;
use View;
use Loader;
class AjaxController extends Controller
{
    /**
     * load the form for editing
     */
    public function editExternalLink()
    {
        $pageId = Request::getInstance()->get('pageid');


I don't know if this is the prefered way, but currently it works for me.