Component name different to the default view name, how to display default view?

by user3804927   Last Updated June 10, 2019 14:10 PM - source

My component is named "com_xsomething" (to make it distinct).

My main view is called "Something".

I want to name my view "Something" rather than "xSomething".

How do I write the main controller's display() function to display the "Something" View and not have Joomla look for "xSomething"?

I tried the below code but it failed miserably:

class xSomethingController extends JControllerLegacy{
    function display(){
        $viewsomething = $this->getView('Something');
        $viewsomething->display();
    }
}

Error:

500 View not found [name, type, prefix]: something, , xsomethingView

I can't name my view "xSomething" because it doesn't make sense in the context my component.



Answers 1


Answered my own question upon reviewing the API documentation and playing around with the code.

I was able to display a different view by specifying the view type and view class prefixes:

class xSomethingController extends JControllerLegacy{
    function display(){
        $viewsomething = $this->getView('Something', 'html', 'xSomethingView');
        $viewsomething->display();
    }
}
user3804927
user3804927
August 19, 2014 04:59 AM

Related Questions




Need some insight from developers

Updated February 19, 2016 01:04 AM


How should I use view.raw.php properly

Updated July 04, 2015 13:04 PM