Same old 500 Layout default not found

143 views
Skip to first unread message

Harold Smith

unread,
Jan 27, 2023, 4:41:22 PM1/27/23
to Joomla! General Development
I wrote a component a few years ago that has worked and sold fine with no support issues.  I updated the code a few months ago for J3J4 compatibility and have been dealing with the Layout not found error for days and months trying to find where it is coming from.

This is a Talent Component that lists talent and photographers..... when I edit a talent and save it's fine but when I close I get the layout not found error and this is the only place in the whole component this happens.

The component works like it's supposed to on J3 with no problem.  I have been back through all of the files to no end many many times and can't find why.
Can anyone Please tell me where I might look to try and fix this.  I must have looked at the controller at least a hundred times hoping it would be there.
I can provide any code that might be needed.

Thank You

Viper

unread,
Jan 28, 2023, 1:07:48 AM1/28/23
to Joomla! General Development
So what description of the error? Turn on debug in Joomla settings to see the stack trace. In additional you can change the LayoutHelper::render() to  LayoutHelper::debug() in your component template to see the path where the Joomla searching for layouts.

Mark Stanton

unread,
Jan 29, 2023, 6:49:56 AM1/29/23
to Joomla! General Development
This sounds like a problem with the redirection, and at a wild guess I'd say it's something to do with the way the redirect URL is written, but as @Viper says, you're not giving us much to go on here.

Peter Tuson

unread,
Jan 29, 2023, 8:39:37 AM1/29/23
to Joomla! General Development
I assume that in your component for J4 you have an admin provider service and a site router service.

If so, my experience is that this error occurs if I have got some naming abit wrong. This could be namespaces, class names or component names.

Regards,

Peter.

Harold Smith

unread,
Jan 30, 2023, 3:15:52 PM1/30/23
to Joomla! General Development
I do have my call stack.  The first line goes directly to the layout file not found exception
call stack.jpg

I have checked for misspelled errors more times than I can count.  Wouldn't this also reflect in J3 if it was spelling error?
I wonder if it isn't something in J4 with the checkEditID function related to Session but all else is good.

My Controller:

// No Direct Access
defined ('_JEXEC') or die('Resticted Aceess');

use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\MVC\Controller\BaseController;

class DlejtalentController extends BaseController {

  public function display( $cachable=false, $urlparams=false){
    $view   = $this->input->get('view','talents');
    $layout = $this->input->get('layout','default');
    $id     = $this->input->getInt('id');
    $this->input->set('view',$view);

    $user = Factory::getUser();
    $isadmin = $user->authorise('core.admin');

    $restrictedViews = array(
      'group' => ComponentHelper::getParams('com_dlejtalent')->get('agent_group_name', 'Agent'),
      'views' => array('agent', 'agents', 'category', 'categories')
    );
    $access = DlejtalentHelper::isDesiredGroup($restrictedViews['group']) || DlejtalentHelper::isDesiredGroup('Super Users') || $isadmin;
    $isAgent = DlejtalentHelper::isDesiredGroup($restrictedViews['group']);
    if (!$access) {
      $this->setMessage(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'),'error');
      $this->setRedirect(Route::_('index.php',false));
      return false;
    } else {
      if ($isAgent) {
        if (in_array($view, $restrictedViews['views'])) {
          $this->setMessage(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'),'error');
          $this->setRedirect(Route::_('index.php?option=com_dlejtalent&view=talents',false));
          return false;
        }
      }
    }
   
    if(($view == 'talent' || $view == 'agent' || $view == 'category' || $view == 'talentfeature' || $view == 'bookingrequest')
    && $layout == 'edit'
    && (!$this->checkEditId('com_dlejtalent.edit.talent',$id) && !$this->checkEditId('com_dlejtalent.edit.agent',$id) && !$this->checkEditId('com_dlejtalent.edit.talentfeature',$id) && !$this->checkEditId('com_dlejtalent.edit.category',$id) && !$this->checkEditId('com_dlejtalent.edit.bookingrequest',$id))){
     
      $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id),'error');
      $this->setRedirect(Route::_('index.php?option=com_dlejtalent&view=talents',false));

      return false;
    }

    parent::display($cachable,$urlparams);
   
    return $this;
  }

}

Harold Smith

unread,
Jan 30, 2023, 3:21:36 PM1/30/23
to Joomla! General Development
On line 3 and 4 of the stack shouldn't it be views/talents instead of  views/talent considering it should redirect to talents?

Viper

unread,
Jan 31, 2023, 3:20:41 AM1/31/23
to Joomla! General Development
Do you have a `tmpl/talent/default.php` file? Looks like view cannot find template.

Harold Smith

unread,
Jan 31, 2023, 11:47:51 AM1/31/23
to Joomla! General Development
Viper,
I do for the frontend view.  I'm at the backend adding a talent and it saves but it will not redirect to my talents view from the talent edit view on close. If I just go back in my browser from the error page I get the error  "You are not permitted to use that link to directly access that page (#10)." with the ID of the talent I am editing.  could this all be because of permissions or just a normal error because I forced the redirect and did not redirect properly?

Reply all
Reply to author
Forward
0 new messages