I am writing code for a view within a customer component and need to bring in a subtemplate based on a parameter passed to the code. If a parameter, $p exists, and the corresponding template can be found, I need my code load it. Otherwise, it needs to load a default template.
I can technically achieve what I am trying to do with the following code, but I don't like the idea of using an exception handler to determine if the template file exists. Is there a joomla method that can first check to see if the template that corresponds to $p exists?
try {
echo $this->loadTemplate($p);
} catch(exception $ex) {
echo $this->loadTemplate("default");
}