Skip to main content
added 1744 characters in body
Source Link

admin\views\music\tmpl\edit.php code

<form action="<?php echo Route::_('index.php?option=com_avisamusicdb&view=music&layout=edit&id=' . (int) $this->item->id); ?>" name="adminForm" id="adminForm" method="post" class="form-validate">
    <?php if (JVERSION < 4 && !empty($this->sidebar)) { ?>
        <div id="j-sidebar-container" class="<?php echo $colClass; ?>2">
            <?php echo $this->sidebar; ?>
        </div>
        <div id="j-main-container" class="<?php echo $colClass; ?>10">
        <?php } else { ?>
            <div id="j-main-container"></div>
        <?php } ?>
        <div class="form-horizontal">
            <div class="<?php echo $rowClass; ?>">
                <div class="<?php echo $colClass; ?>12">
                    <?php echo HTMLHelper::_("$tab.startTabSet", 'myTab', array('active' => 'basic_configuration')); ?>
                    <?php echo HTMLHelper::_("$tab.addTab", 'myTab', 'basic_configuration', Text::_('COM_AVISAMUSICDB_FIELDSET_BASIC_INFO')); ?>
                    <?php echo $this->form->renderFieldset('basic_configuration'); ?>
                    <?php echo HTMLHelper::_("$tab.endTab"); ?>

                    <?php echo HTMLHelper::_("$tab.addTab", 'myTab', 'music_links', Text::_('COM_AVISAMUSICDB_FIELDSET_MUSIC_LINKS')); ?>
                    <?php echo $this->form->renderFieldset('music_links'); ?>
                    <?php echo HTMLHelper::_("$tab.endTab"); ?>

                    <?php echo HTMLHelper::_("$tab.addTab", 'myTab', 'music_trailers', Text::_('COM_AVISAMUSICDB_FIELDSET_MUSIC_TRAILER_URLS')); ?>
                    <?php echo $this->form->renderFieldset('music_trailers'); ?>
                    <?php echo HTMLHelper::_("$tab.endTab"); ?>

                    <?php echo HTMLHelper::_("$tab.endTabSet"); ?>
                </div>
            </div>
        </div>
        <input type="hidden" name="task" value="music.edit" />
        <?php echo HTMLHelper::_('form.token'); ?>
        </div>
</form>

admin\views\music\tmpl\edit.php code

<form action="<?php echo Route::_('index.php?option=com_avisamusicdb&view=music&layout=edit&id=' . (int) $this->item->id); ?>" name="adminForm" id="adminForm" method="post" class="form-validate">
    <?php if (JVERSION < 4 && !empty($this->sidebar)) { ?>
        <div id="j-sidebar-container" class="<?php echo $colClass; ?>2">
            <?php echo $this->sidebar; ?>
        </div>
        <div id="j-main-container" class="<?php echo $colClass; ?>10">
        <?php } else { ?>
            <div id="j-main-container"></div>
        <?php } ?>
        <div class="form-horizontal">
            <div class="<?php echo $rowClass; ?>">
                <div class="<?php echo $colClass; ?>12">
                    <?php echo HTMLHelper::_("$tab.startTabSet", 'myTab', array('active' => 'basic_configuration')); ?>
                    <?php echo HTMLHelper::_("$tab.addTab", 'myTab', 'basic_configuration', Text::_('COM_AVISAMUSICDB_FIELDSET_BASIC_INFO')); ?>
                    <?php echo $this->form->renderFieldset('basic_configuration'); ?>
                    <?php echo HTMLHelper::_("$tab.endTab"); ?>

                    <?php echo HTMLHelper::_("$tab.addTab", 'myTab', 'music_links', Text::_('COM_AVISAMUSICDB_FIELDSET_MUSIC_LINKS')); ?>
                    <?php echo $this->form->renderFieldset('music_links'); ?>
                    <?php echo HTMLHelper::_("$tab.endTab"); ?>

                    <?php echo HTMLHelper::_("$tab.addTab", 'myTab', 'music_trailers', Text::_('COM_AVISAMUSICDB_FIELDSET_MUSIC_TRAILER_URLS')); ?>
                    <?php echo $this->form->renderFieldset('music_trailers'); ?>
                    <?php echo HTMLHelper::_("$tab.endTab"); ?>

                    <?php echo HTMLHelper::_("$tab.endTabSet"); ?>
                </div>
            </div>
        </div>
        <input type="hidden" name="task" value="music.edit" />
        <?php echo HTMLHelper::_('form.token'); ?>
        </div>
</form>
added 3007 characters in body
Source Link

after iI am trying to make a music component for Joomla 4

On the backend, my other forms work fine and the data is stored correctly in the database ( celebrity , album , etc...)

In the music form, when I click on Save&Close i receivethe save and exit button, I get an error 500 Layout default not found. but the information is saved well in the database.

The codes used to display the forms are almost similar to each other and all the forms work correctly in the backend, but the music form has an error.

The code used in com_myext/admin/views/music/view.html.php file for music

what wrong hereThe code used in ?com_myext/admin/views/musics/view.html.php file for musics

defined('_JEXEC') or die('Restricted Access');

use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;

class AvisamusicdbViewMusics extends HtmlView
{
    protected $items;
    protected $state;
    protected $pagination;
    protected $model;
    public $filterForm, $activeFilters;
public function display($tpl = null)
    {
        $this->items            = $this->get('Items');
        $this->state            = $this->get('State');
        $this->pagination       = $this->get('Pagination');
        $this->model            = $this->getModel('musics');
        $this->filterForm       = $this->get('FilterForm');
        $this->activeFilters    = $this->get('ActiveFilters');


        if (count($errors = $this->get('Errors'))) {
            throw new \Exception(implode('<br>', $errors), 500);
        }

        AvisamusicdbHelper::addSubmenu('musics');
        $this->sidebar = JHtmlSidebar::render();

        $this->addToolbar();
        return parent::display($tpl);
    }
protected function addToolbar()
    {
        $state  = $this->get('State');
        $canDo  = ContentHelper::getActions('com_avisamusicdb', 'component');
        $user   = Factory::getUser();
        $bar    = Toolbar::getInstance('toolbar');

        if ($canDo->get('core.create')) {
            ToolbarHelper::addNew('music.add');
        }

        if ($canDo->get('core.edit')) {
            ToolbarHelper::editList('music.edit');
        }

        if ($canDo->get('core.edit.state')) {
            ToolbarHelper::publish('musics.publish', 'JTOOLBAR_PUBLISH', true);
            ToolbarHelper::unpublish('musics.unpublish', 'JTOOLBAR_UNPUBLISH', true);
            ToolbarHelper::archiveList('musics.archive');
            ToolbarHelper::checkin('musics.checkin');
        }
if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) {
            ToolbarHelper::deleteList('', 'musics.delete', 'JTOOLBAR_EMPTY_TRASH');
        } elseif ($canDo->get('core.edit.state')) {
            ToolbarHelper::trash('musics.trash');
        }

        if ($canDo->get('core.admin')) {
            ToolbarHelper::preferences('com_avisamusicdb');
        }

        JHtmlSidebar::setAction('index.php?option=com_avisamusicdb&view=musics');
        ToolbarHelper::title(sprintf('%s: %s', Text::_('COM_AVISAMUSICDB'), Text::_('COM_AVISAMUSICDB_TITLE_MUSICS')), '');
    }
}

The structure of my folders and files is as follows i upload celebrity & celebrities for example for better understanding ( celebrities code , something like musics code )

enter image description hereenter image description here

after i click on Save&Close i receive error

what wrong here ?

enter image description here

I am trying to make a music component for Joomla 4

On the backend, my other forms work fine and the data is stored correctly in the database ( celebrity , album , etc...)

In the music form, when I click on the save and exit button, I get an error 500 Layout default not found. but the information is saved well in the database.

The codes used to display the forms are almost similar to each other and all the forms work correctly in the backend, but the music form has an error.

The code used in com_myext/admin/views/music/view.html.php file for music

The code used in com_myext/admin/views/musics/view.html.php file for musics

defined('_JEXEC') or die('Restricted Access');

use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;

class AvisamusicdbViewMusics extends HtmlView
{
    protected $items;
    protected $state;
    protected $pagination;
    protected $model;
    public $filterForm, $activeFilters;
public function display($tpl = null)
    {
        $this->items            = $this->get('Items');
        $this->state            = $this->get('State');
        $this->pagination       = $this->get('Pagination');
        $this->model            = $this->getModel('musics');
        $this->filterForm       = $this->get('FilterForm');
        $this->activeFilters    = $this->get('ActiveFilters');


        if (count($errors = $this->get('Errors'))) {
            throw new \Exception(implode('<br>', $errors), 500);
        }

        AvisamusicdbHelper::addSubmenu('musics');
        $this->sidebar = JHtmlSidebar::render();

        $this->addToolbar();
        return parent::display($tpl);
    }
protected function addToolbar()
    {
        $state  = $this->get('State');
        $canDo  = ContentHelper::getActions('com_avisamusicdb', 'component');
        $user   = Factory::getUser();
        $bar    = Toolbar::getInstance('toolbar');

        if ($canDo->get('core.create')) {
            ToolbarHelper::addNew('music.add');
        }

        if ($canDo->get('core.edit')) {
            ToolbarHelper::editList('music.edit');
        }

        if ($canDo->get('core.edit.state')) {
            ToolbarHelper::publish('musics.publish', 'JTOOLBAR_PUBLISH', true);
            ToolbarHelper::unpublish('musics.unpublish', 'JTOOLBAR_UNPUBLISH', true);
            ToolbarHelper::archiveList('musics.archive');
            ToolbarHelper::checkin('musics.checkin');
        }
if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) {
            ToolbarHelper::deleteList('', 'musics.delete', 'JTOOLBAR_EMPTY_TRASH');
        } elseif ($canDo->get('core.edit.state')) {
            ToolbarHelper::trash('musics.trash');
        }

        if ($canDo->get('core.admin')) {
            ToolbarHelper::preferences('com_avisamusicdb');
        }

        JHtmlSidebar::setAction('index.php?option=com_avisamusicdb&view=musics');
        ToolbarHelper::title(sprintf('%s: %s', Text::_('COM_AVISAMUSICDB'), Text::_('COM_AVISAMUSICDB_TITLE_MUSICS')), '');
    }
}

The structure of my folders and files is as follows i upload celebrity & celebrities for example for better understanding ( celebrities code , something like musics code )

enter image description here

added 87 characters in body
Source Link

after i click on Save&Close i receive error

defined('_JEXEC') or die('Restricted Access');

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Helper\ContentHelper;

class AvisamusicdbViewMusic extends HtmlView
{
    protected $item;
    protected $form;

    public function display($tpl = null)
    {
        $this->item = $this->get('Item');
        $this->form = $this->get('Form');

        if (count($errors = $this->get('Errors'))) {
            throw new \Exception(implode('<br>', $errors), 500);
        }

        $this->addToolbar();

        return parent::display($tpl);
    }

    protected function addToolbar()
    {
        $input = Factory::getApplication()->input;
        $input->set('hidemainmenu', true);

        $user = Factory::getUser();
        $userId = $user->id;
        $isNew = $this->item->id == 0;
        $canDo = ContentHelper::getActions('com_avisamusicdb', 'component');

        ToolbarHelper::title(sprintf('%s: %s', Text::_('COM_AVISAMUSICDB'), Text::_('COM_AVISAMUSICDB_TITLE_MUSICS_EDIT')), '');

        if ($canDo->get('core.edit')) {
            ToolbarHelper::apply('music.apply', 'JTOOLBAR_APPLY');
            ToolbarHelper::save('music.save', 'JTOOLBAR_SAVE');
            ToolbarHelper::save2new('music.save2new');
            ToolbarHelper::save2copy('music.save2copy');
        }

        ToolbarHelper::cancel('music.cancel', 'JTOOLBAR_CLOSE');
    }
}

what wrong here ?

enter image description here

after i click on Save&Close i receive error

defined('_JEXEC') or die('Restricted Access');

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Helper\ContentHelper;

class AvisamusicdbViewMusic extends HtmlView
{
    protected $item;
    protected $form;

    public function display($tpl = null)
    {
        $this->item = $this->get('Item');
        $this->form = $this->get('Form');

        if (count($errors = $this->get('Errors'))) {
            throw new \Exception(implode('<br>', $errors), 500);
        }

        $this->addToolbar();

        return parent::display($tpl);
    }

    protected function addToolbar()
    {
        $input = Factory::getApplication()->input;
        $input->set('hidemainmenu', true);

        $user = Factory::getUser();
        $userId = $user->id;
        $isNew = $this->item->id == 0;
        $canDo = ContentHelper::getActions('com_avisamusicdb', 'component');

        ToolbarHelper::title(sprintf('%s: %s', Text::_('COM_AVISAMUSICDB'), Text::_('COM_AVISAMUSICDB_TITLE_MUSICS_EDIT')), '');

        if ($canDo->get('core.edit')) {
            ToolbarHelper::apply('music.apply', 'JTOOLBAR_APPLY');
            ToolbarHelper::save('music.save', 'JTOOLBAR_SAVE');
            ToolbarHelper::save2new('music.save2new');
            ToolbarHelper::save2copy('music.save2copy');
        }

        ToolbarHelper::cancel('music.cancel', 'JTOOLBAR_CLOSE');
    }
}

what wrong here ?

after i click on Save&Close i receive error

defined('_JEXEC') or die('Restricted Access');

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Helper\ContentHelper;

class AvisamusicdbViewMusic extends HtmlView
{
    protected $item;
    protected $form;

    public function display($tpl = null)
    {
        $this->item = $this->get('Item');
        $this->form = $this->get('Form');

        if (count($errors = $this->get('Errors'))) {
            throw new \Exception(implode('<br>', $errors), 500);
        }

        $this->addToolbar();

        return parent::display($tpl);
    }

    protected function addToolbar()
    {
        $input = Factory::getApplication()->input;
        $input->set('hidemainmenu', true);

        $user = Factory::getUser();
        $userId = $user->id;
        $isNew = $this->item->id == 0;
        $canDo = ContentHelper::getActions('com_avisamusicdb', 'component');

        ToolbarHelper::title(sprintf('%s: %s', Text::_('COM_AVISAMUSICDB'), Text::_('COM_AVISAMUSICDB_TITLE_MUSICS_EDIT')), '');

        if ($canDo->get('core.edit')) {
            ToolbarHelper::apply('music.apply', 'JTOOLBAR_APPLY');
            ToolbarHelper::save('music.save', 'JTOOLBAR_SAVE');
            ToolbarHelper::save2new('music.save2new');
            ToolbarHelper::save2copy('music.save2copy');
        }

        ToolbarHelper::cancel('music.cancel', 'JTOOLBAR_CLOSE');
    }
}

what wrong here ?

enter image description here

Source Link
Loading