I'm currently building a new Joomla! 4 component from scratch by following along a series of blog posts since I am new to Joomla! and its development.
I am using Joomla! 4.1.5
Unfortunately I am not able to get the front-end part working while the back-end part works fine. I always get the "View not found" error when trying to visit any front-end site of the component.
The error shown is this:
404 View not found [name, type, prefix]: foo, html, foo\component\bar\site\controller\displayView
What I did is:
- Add a DisplayController to the site part with path
com_foo/src/Controller/DisplayController.php
namespace Foo\Component\Bar\Site\Controller;
use Joomla\CMS\MVC\Controller\BaseController;
class DisplayController extends BaseController
{
public function display($cachable = false, $urlparams = []): DisplayController
{
return parent::display($cachable, $urlparams);
}
}
- Add a View to the site part with path
com_foo/src/View/Foo/HtmlView.php
namespace Foo\Component\Bar\Site\View\Foo;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
class HtmlView extends BaseHtmlView
{
public function display($template = null)
{
parent::display($template);
}
}
- Add a template with very basic content to the site part with path:
com_foo/tmpl/foo/default.php
default template for foo part
- Install component (with uninstalling the old one before).
- Go to URL
http://localhost/index.php?option=com_foo&view=foo
- The error is shown