Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • doorknob Friend
    #193387

    I thought it worth sharing my experience in developing a template block for T3 Blank because it took a long time to track down the cause of an issue that I created inadvertently.

    When I loaded the template into the live site and started to configure it, I found that the layout tab was empty and I got an error message “The layout cannot be loaded. There might be some errors in the layout file.”. It didn’t take long to find out that this was happening because the t3 template (modified T3 Blank) was not the default template but it took a lot longer to find out why this caused a php error.

    One of the modifications had been to add a new template block to add some scripts to the template for miscellaneous purposes,. One of the new processes loads a helper class from a file in the template directory structure. This works fine when the template is used in the frontend in the normal way but seemed to be triggering a php error when run in the backend.

    If the template is run in the normal way, it can only be active if it is the default template in which case the code:

    JFactory::getApplication()->getTemplate();
    will always return the name of the correct template. I was using this to create the path when loading the helper file and to create the URLs for js files. Unfortunately, when the template manager style editing page creates the layout, the above code may returns the name of the wrong template if t3 blank is not the default template.

    T3 has a method that returns the name of the template when working in the backend so I tried using ‘isAdmin()’ to determine when to use the regular Joomla method and when to use the T3 method. That didn’t work because when creating the layout in the backend, isAdmin() returns FALSE. Unfortunately we can’t use the T3 method in all circumstances because it returns an empty string in the frontend. I finally concluded that the only safe way to get the template name in a template block file is:

    $template = T3::getTemplate(true);

    if (empty($template)) {
    $template = JFactory::getApplication()->getTemplate();
    }

    I hope this saves some frustration for anyone doing something similar.

    alexsmirnov Friend
    #528812

    Much appreciated!

    On what Joomla version did you play with this please?

    doorknob Friend
    #528827

    <em>@alexsmirnov 419057 wrote:</em><blockquote>On what Joomla version did you play with this please?</blockquote>

    It will have been whichever of the J3.2.n line was current at the time (3.2.1?)

    alexsmirnov Friend
    #528832

    Cheers once again.

Viewing 4 posts - 1 through 4 (of 4 total)

This topic contains 4 replies, has 2 voices, and was last updated by  alexsmirnov 10 years, 7 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum