Nick Cardoso
Nick Cardoso

Reputation: 21733

Concrete5 - How do I get the selected template inside my block controller?

I'm using Concrete5 5.6.0 and trying to make my Block more customisable by using LESS.

I followed the information here: http://www.codeblog.ch/2014/01/concrete5-use-less-files-for-block-templates/ and Remo's code that it links to but getCurrentTemplate() does not exist on the Controller

What is the correct way for me to get the current template to work with this code?

Upvotes: 0

Views: 716

Answers (2)

Willem
Willem

Reputation: 101

This will work in 5.7

$b = $this->getBlockObject();
if (is_object($b)) {
    $bvt = new BlockViewTemplate($b);
    if (is_object($bvt)) {
        $templatepath = $bvt->getTemplate();
        list($junk, $template) = explode('/templates', $templatepath);
        if (strlen($template) > 0) {    // any template name left ?
            // $template holds the rest of the path with the template name
        } else {
            // standard template
        }
    }
}

Upvotes: 1

JohntheFish
JohntheFish

Reputation: 167

There is a snippet of code in this howto to get the current template name. Not a complete solution, but maybe it will provide some ideas.

http://www.concrete5.org/documentation/how-tos/developers/load-template-specific-assets/

Upvotes: 1

Related Questions