1

This my request

enter image description here

NewAction.php to handle the request

enter image description here

enter image description here

this is result of request

I don't have blog_post_new layout, How it will work ?

2
  • This issue occurred because your NewAction controller extends the Post controller, which means it inherits the layout from the Post controller. As a result, the Post controller's layout is being used in your NewAction controller. Commented Jul 2 at 11:05
  • yes sir I got it, thank you very much
    – ducanh
    Commented Jul 2 at 14:29

1 Answer 1

1

This is not Magento codebase, but a third-party module, specially Magefan_Blog.

  1. The \Magefan\Blog\Controller\Adminhtml\Post\NewAction class extends the \Magefan\Blog\Controller\Adminhtml\Post class. Reference: https://github.com/magefan/module-blog/blob/2.11.4/Controller/Adminhtml/Post/NewAction.php
  2. The \Magefan\Blog\Controller\Adminhtml\Post class extends the \Magefan\Blog\Controller\Adminhtml\Actions class. Reference: https://github.com/magefan/module-blog/blob/2.11.4/Controller/Adminhtml/Post.php
  3. The \Magefan\Blog\Controller\Adminhtml\Actions class extends the \Magefan\Community\Controller\Adminhtml\Actions class. Reference: https://github.com/magefan/module-blog/blob/2.11.4/Controller/Adminhtml/Actions.php

The \Magefan\Community\Controller\Adminhtml\Actions class, is designed to handle requests for a list of actions, including 'index', 'grid', 'new', 'edit', 'save', 'duplicate', 'delete', 'config', and 'massStatus'. Reference: https://github.com/magefan/module-community/blob/2.1.28/Controller/Adminhtml/Actions.php

/**
 * Action execute
 * @return \Magento\Framework\Controller\ResultInterface
 */
public function execute()
{
    $_preparedActions = ['index', 'grid', 'new', 'edit', 'save', 'duplicate', 'delete', 'config', 'massStatus'];
    $_action = $this->getRequest()->getActionName();
    if (in_array($_action, $_preparedActions)) {
        $method = '_'.$_action.'Action';

        $this->_beforeAction();
        $this->$method();
        $this->_afterAction();
    }
}

The new action, in turn, being handled by the call $this->_newAction():

/**
 * New action
 * @return void
 */
protected function _newAction()
{
    $this->_forward('edit');
}

As a result, the new action (<base_url>/admin/blog/post/new), is forwarded to the edit action (<base_url>/admin/blog/post/edit). The edit action has its layout file declared at <Magefan_Blog_module_dir>/view/adminhtml/layout/blog_post_edit.xml. Reference: https://github.com/magefan/module-blog/blob/2.11.4/view/adminhtml/layout/blog_post_edit.xml

1
  • Thank you for your explaination, i completely understood <3
    – ducanh
    Commented Jul 2 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.