Incorrect list view being called from edit view

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
bertyterty
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jan 11, 2017 1:13 pm

Incorrect list view being called from edit view

Postby bertyterty » Wed Jan 11, 2017 1:47 pm

Hi everyone

This is my first post, but I have been developing with Joomla on and off for the past five years.

I'm currently creating an extension for my church website that will allow us to easily upload and share audio recordings. The component is called Sermonlibrary, and I have four views in the admin area (this is where the issue is):-
    Sermons (List)
    Sermon (Edit)
    Seriess (List)
    Series (Edit)

The Sermons and Sermon view are working fine, I can upload the files and view them in the front end. I am now adding the Seriess and Series views which will create groups for the sermons. I did think I could use the category manager for this, but I figured it would be too complicated for our users to update (I need something that is very simple for them).

When I am in the Seriess view (List), I can see the series that I have created. When I click to edit one of them, I get the Series view which uses the edit layout file. Now once I am in this view, I can click save (series.apply) and the record is updated. If I click Save & Close, or Close, I get a 404 error:-
404 View not found [name, type, prefix]: sery, html, sermonlibraryView


I have gone over the code as best I can. I did copy and paste a lot of it from the Sermons and Sermon views, so I can only assume I've missed something, but I can't figure out how "sery" could even be loaded into the list_view variable. It should be loading SermonlibraryViewSeriess.

It's also worth me noting that when I click Save & Close, I get the error but the record is updated and checked in as well. I have included the PHP for the view, model and controller files, as well as the result from the FPA, just in case it helps.

I'm wondering if it is because the plural and singular names are so close to each other, but having thought about it, I don't understand how it could come up with the word sery.

I couldn't see it in the FPA, but I am running Joomla 3.6.5, platform 13.1.0

Thanks for any help

Views / Series / view.html.php

Code: Select all

<?php

defined('_JEXEC') or die;

class SermonlibraryViewSeries extends JViewLegacy {
    protected $item;
   
    protected $form;
   
    protected $table;
   
    public function display($tpl = null) {
        $this->item     = $this->get('Item');
        $this->form     = $this->get('Form');
        $this->table    = $this->get('Table');
       
        if(count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode("\n", $errors));
            return false;
        }
       
        $this->addToolbar();
        parent::display($tpl);
    }
   
    protected function addToolbar() {
        JFactory::getApplication()->input->set('hidemainmenu', true);
       
        JToolbarHelper::title(JText::_('COM_SERMONLIBRARY_MANAGER_SERIES'), '');
        JToolbarHelper::apply('series.apply');
        JToolbarHelper::save('series.save');
       
        if(empty($this->item->id)) {
            JToolbarHelper::cancel('series.cancel');
        } else {
            JToolbarHelper::cancel('series.cancel', 'JTOOLBAR_CLOSE');
        }
    }
}



Views / Series / Tmpl / edit.php

Code: Select all

<?php

defined('_JEXEC') or die;
?>

<form action="<?php echo JRoute::_('index.php?option=com_sermonlibrary&layout=edit&id='.(int)$this->item->id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate">
    <div class="row-fluid">
        <div class="span10 form-horizontal">
           
            <fieldset>
                <?php echo JHtml::_('bootstrap.startPane', 'myTab', array('active' => 'details')); ?>
               
                <?php echo JHtml::_('bootstrap.addPanel', 'myTab', 'details', empty($this->item->id) ? JText::_('COM_SERMONLIBRARY_NEW_SERIES', true) : JText::sprintf('COM_SERMONLIBRARY_EDIT_SERIES', $this->item->id, true)); ?>
                <?php foreach($this->form->getFieldset('seriesFields') as $field) : ?>
                <div class="control-group">
                    <div class="control-label">
                        <?php echo $field->label; ?>
                    </div>
                    <div class="controls">
                        <?php echo $field->input; ?>
                    </div>
                </div>
                <?php endforeach; ?>
                <?php echo JHtml::_('bootstrap.endPanel'); ?>
               
                <input type="hidden" name="task" value="" />
                <?php echo JHtml::_('form.token'); ?>
                <?php echo JHtml::_('bootstrap.endPane'); ?>
            </fieldset>
        </div>
    </div>
</form>



Controllers / series.php

Code: Select all

<?php

defined('_JEXEC') or die;

class SermonlibraryControllerSeries extends JControllerForm {
   
}



Models / series.php

Code: Select all

<?php

defined('_JEXEC') or die;

class SermonlibraryModelSeries extends JModelAdmin {
    protected $text_prefix = 'COM_SERMONLIBRARY';
   
    public function getTable($type = 'Series', $prefix = 'SermonlibraryTable', $config = array()) {
        return JTable::getInstance($type, $prefix, $config);
    }
   
    public function getForm($data = array(), $loadData = true) {
        $app = JFactory::getApplication();
       
        $form = $this->loadForm('com_sermonlibrary.series', 'series', array('control' => 'jform', 'load_data' => $loadData));
       
        if(empty($form)) {
            return false;
        }
       
        return $form;
    }
   
    protected function loadFormData() {
        $data = JFactory::getApplication()->getUserState('com_sermonlibrary.edit.series.data', array());
       
        if(empty($data)) {
            $data = $this->getItem();
        }
       
        return $data;
    }
   
    protected function prepareTable($table) {
        $table->title       = htmlspecialchars_decode($table->title, ENT_QUOTES);
        $table->description = htmlspecialchars_decode($table->description, ENT_QUOTES);
    }
}



Models / Forms / series.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<form enctype="multipart/form-data">
    <fieldset name="seriesFields">
        <field name="id" type="text" default="0" label="JGLOBAL_FIELD_ID_LABEL"
            readonly="true" class="readonly"
            description="JGLOBAL_FIELD_ID_DESC" />
       
        <field name="state" type="list"
            label="JSTATUS" description="JFIELD_PUBLISHED_DESC"
            class="chzn-color-state" size="1" default="1" >
            <option value="1">JPUBLISHED</option>
            <option value="0">JUNPUBLISHED</option>
            <option value="2">JARCHIVED</option>
            <option value="-2">JTRASHED</option>
        </field>
       
        <field name="title" type="text" class="inputbox"
            size="40" label="JGLOBAL_TITLE"
            description="COM_SERMONLIBRARY_FIELD_TITLE_DESC" required="true" />
    </fieldset>
</form>


Last PHP Error(s) Reported :: Forum Post Assistant (v1.2.7) : 11th January 2017 wrote:[11-Jan-2017 13:21:55 Europe/London] PHP 1. {main}() /Users/andrew/Sites/BFC/htdocs/fpa-en.php:0
Forum Post Assistant (v1.2.7) : 11th January 2017 wrote:
Basic Environment :: wrote:Joomla! Instance :: .- ()
Joomla! Configured :: Yes | Read-Only (444) | Owner: andrew (uid: 1/gid: 1) | Group: staff (gid: 1) | Valid For: 1.6
Configuration Options :: Offline: 0 | SEF: 1 | SEF Suffix: 0 | SEF ReWrite: 1 | .htaccess/web.config: Yes | GZip: 0 | Cache: 0 | FTP Layer: 0 | SSL: 0 | Error Reporting: default | Site Debug: 1 | Database Credentials Present: Yes

Host Configuration :: OS: Darwin | OS Version: 16.3.0 | Technology: x86_64 | Web Server: Apache | Encoding: gzip, deflate | Doc Root: /Users/andrew/Sites/BFC/htdocs | System TMP Writable: Yes

PHP Configuration :: Version: 7.0.12 | PHP API: cgi-fcgi | Session Path Writable: Yes | Display Errors: 1 | Error Reporting: 32767 | Log Errors To: /Applications/MAMP/logs/php_error.log | Last Known Error: 11th January 2017 13:23:31. | Register Globals: | Magic Quotes: | Safe Mode: | Open Base: | Uploads: 1 | Max. Upload Size: 32M | Max. POST Size: 32M | Max. Input Time: 60 | Max. Execution Time: 30 | Memory Limit: 128M

MySQL Configuration :: Connection Error: : Database Credentials Present? in Configuration...
Detailed Environment :: wrote:PHP Extensions :: Core (7.0.12) | date (7.0.12) | libxml (7.0.12) | openssl (7.0.12) | pcre (7.0.12) | sqlite3 (0.7-dev) | zlib (7.0.12) | bcmath (7.0.12) | bz2 (7.0.12) | calendar (7.0.12) | ctype (7.0.12) | curl (7.0.12) | dom (20031129) | hash (1.0) | fileinfo (1.0.5) | filter (7.0.12) | ftp (7.0.12) | gd (7.0.12) | SPL (7.0.12) | iconv (7.0.12) | intl (1.1.0) | json (1.4.0) | ldap (7.0.12) | mbstring (7.0.12) | session (7.0.12) | standard (7.0.12) | mysqlnd (mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $) | PDO (7.0.12) | pdo_mysql (7.0.12) | pdo_sqlite (7.0.12) | Phar (2.0.2) | posix (7.0.12) | readline (7.0.12) | Reflection (7.0.12) | mysqli (7.0.12) | SimpleXML (7.0.12) | soap (7.0.12) | sockets (7.0.12) | exif (1.4 $Id: 8bdc0c8f27c2c9dd1f7551f1f9fe3ab57a06a4b1 $) | tokenizer (7.0.12) | wddx (7.0.12) | xml (7.0.12) | xmlreader (7.0.12) | xmlwriter (7.0.12) | xsl (7.0.12) | zip (1.13.4) | cgi-fcgi () | imap (7.0.12) | gettext (7.0.12) | mcrypt (7.0.12) | pgsql (7.0.12) | pdo_pgsql (7.0.12) | xdebug (2.4.1) | Zend Engine (3.0.0) |
Potential Missing Extensions :: mysql | suhosin |

Switch User Environment (Experimental) :: PHP CGI: Yes | Server SU: Yes | PHP SU: Yes | Custom SU (LiteSpeed/Cloud/Grid): Yes
Potential Ownership Issues: No
Folder Permissions :: wrote:Core Folders :: images/ (757) | components/ (757) | modules/ (757) | plugins/ (757) | language/ (757) | templates/ (757) | cache/ (757) | logs/ (---) | tmp/ (757) | administrator/components/ (757) | administrator/modules/ (757) | administrator/language/ (757) | administrator/templates/ (757) |

Elevated Permissions (First 10) :: administrator/ (757) | administrator/cache/ (757) | administrator/components/ (757) | administrator/components/com_admin/ (757) | administrator/components/com_admin/controllers/ (757) | administrator/components/com_admin/helpers/ (757) | administrator/components/com_admin/helpers/html/ (757) | administrator/components/com_admin/models/ (757) | administrator/components/com_admin/models/forms/ (757) | administrator/components/com_admin/postinstall/ (757) |
Extensions Discovered :: wrote:Components :: SITE :: com_mailto (3.0.0) | com_wrapper (3.0.0) |
Components :: ADMIN :: com_admin (3.0.0) | com_ajax (3.2.0) | com_banners (3.0.0) | com_cache (3.0.0) | com_categories (3.0.0) | com_checkin (3.0.0) | com_config (3.0.0) | com_content (3.0.0) | com_contenthistory (3.2.0) | com_cpanel (3.0.0) | com_finder (3.0.0) | com_folio (1.4.2) | com_installer (3.0.0) | com_joomlaupdate (3.6.2) | com_languages (3.0.0) | com_login (3.0.0) | com_media (3.0.0) | com_menus (3.0.0) | com_messages (3.0.0) | com_modules (3.0.0) | com_newsfeeds (3.0.0) | com_plugins (3.0.0) | com_postinstall (3.2.0) | com_redirect (3.0.0) | com_search (3.0.0) | COM_SERMONLIBRARY (1.0.0) | com_tags (3.1.0) | com_templates (3.0.0) | com_users (3.0.0) | com_widgetkit (2.4.4) |

Modules :: SITE :: mod_articles_archive (3.0.0) | mod_articles_categories (3.0.0) | mod_articles_category (3.0.0) | mod_articles_latest (3.0.0) | mod_articles_news (3.0.0) | mod_articles_popular (3.0.0) | mod_banners (3.0.0) | mod_breadcrumbs (3.0.0) | mod_custom (3.0.0) | mod_feed (3.0.0) | mod_finder (3.0.0) | mod_footer (3.0.0) | mod_languages (3.5.0) | mod_login (3.0.0) | mod_menu (3.0.0) | mod_random_image (3.0.0) | mod_related_items (3.0.0) | mod_search (3.0.0) | mod_stats (3.0.0) | mod_syndicate (3.0.0) | mod_tags_popular (3.1.0) | mod_tags_similar (3.1.0) | mod_users_latest (3.0.0) | mod_whosonline (3.0.0) | Widgetkit (2.4.4) | mod_wrapper (3.0.0) |
Modules :: ADMIN :: mod_custom (3.0.0) | mod_feed (3.0.0) | mod_latest (3.0.0) | mod_logged (3.0.0) | mod_login (3.0.0) | mod_menu (3.0.0) | mod_multilangstatus (3.0.0) | mod_popular (3.0.0) | mod_quickicon (3.0.0) | mod_stats_admin (3.0.0) | mod_status (3.0.0) | mod_submenu (3.0.0) | mod_title (3.0.0) | mod_toolbar (3.0.0) | mod_version (3.0.0) |

Plugins :: SITE :: plg_authentication_cookie (3.0.0) | plg_authentication_gmail (3.0.0) | plg_authentication_joomla (3.0.0) | plg_authentication_ldap (3.0.0) | plg_captcha_recaptcha (3.4.0) | plg_content_emailcloak (3.0.0) | plg_content_finder (3.0.0) | plg_content_joomla (3.0.0) | plg_content_loadmodule (3.0.0) | plg_content_pagebreak (3.0.0) | plg_content_pagenavigation (3.0.0) | plg_content_vote (3.0.0) | Content - Widgetkit (2.4.4) | plg_editors_codemirror (5.18.0) | plg_editors_tinymce (4.4.3) | plg_editors-xtd_article (3.0.0) | plg_editors-xtd_image (3.0.0) | plg_editors-xtd_module (3.5.0) | plg_editors-xtd_pagebreak (3.0.0) | plg_editors-xtd_readmore (3.0.0) | Editors-XTD - Widgetkit (2.4.4) | plg_extension_joomla (3.0.0) | plg_finder_categories (3.0.0) | plg_finder_contacts (3.0.0) | plg_finder_content (3.0.0) | plg_finder_newsfeeds (3.0.0) | plg_finder_tags (3.0.0) | PLG_INSTALLER_FOLDERINSTALLER (3.6.0) | plg_installer_packageinstaller (3.6.0) | PLG_INSTALLER_URLINSTALLER (3.6.0) | plg_installer_webinstaller (1.1.0) | Installer - YOOtheme (1.0.0) | plg_quickicon_extensionupdate (3.0.0) | plg_quickicon_joomlaupdate (3.0.0) | plg_search_categories (3.0.0) | plg_search_contacts (3.0.0) | plg_search_content (3.0.0) | plg_search_newsfeeds (3.0.0) | plg_search_tags (3.0.0) | plg_system_cache (3.0.0) | plg_system_debug (3.0.0) | PLG_SYSTEM_FMALERTCOOKIES (1.3.3) | plg_system_highlight (3.0.0) | plg_system_languagecode (3.0.0) | plg_system_languagefilter (3.0.0) | plg_system_log (3.0.0) | plg_system_logout (3.0.0) | plg_system_p3p (3.0.0) | plg_system_redirect (3.0.0) | plg_system_remember (3.0.0) | plg_system_sef (3.0.0) | Shortcuts JX (3.1.1) | plg_system_stats (3.5.0) | plg_system_updatenotification (3.5.0) | System - Widgetkit K2 (2.4.4) | System - Widgetkit ZOO (2.4.4) | plg_twofactorauth_totp (3.2.0) | plg_twofactorauth_yubikey (3.2.0) | plg_user_contactcreator (3.0.0) | plg_user_joomla (3.0.0) | plg_user_profile (3.0.0) |
Templates Discovered :: wrote:Templates :: SITE :: beez3 (3.1.0) | protostar (1.0) | yoo_venice (1.0.5) |
Templates :: ADMIN :: hathor (3.0.0) | isis (1.0) |

bertyterty
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jan 11, 2017 1:13 pm

Re: Incorrect list view being called from edit view

Postby bertyterty » Wed Jan 11, 2017 5:50 pm

I'm not sure if this has fixed it, but the Seriess view didn't have a menu item in the administration area (I was just accessing it with &view=seriess in the url). I have just added it to the installation xml and then reinstalled the component and the issue has been resolved.

Edit

Turns out it wasn't fixed, I just clicked the wrong link! DOH!!!

Still getting the same 404 veiw not found for 'sery' when clicking Save & Close, or Close.

bertyterty
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jan 11, 2017 1:13 pm

Re: Incorrect list view being called from edit view

Postby bertyterty » Wed Jan 11, 2017 7:50 pm

Ok I managed to fix this now.

Just in case anyone has anything like this in the future, it is due to Joomla automatically trying to find the plural version of the edit view class.

/libraries/legacy/controllers/form.php

Code: Select all

$plural = array(
            array('/(x|ch|ss|sh)$/i', "$1es"),
            array('/([^aeiouy]|qu)y$/i', "$1ies"),
            array('/([^aeiouy]|qu)ies$/i', "$1y"),
            array('/(bu)s$/i', "$1ses"),
            array('/s$/i', "s"),
            array('/$/', "s"),


This code snippet is from the construct method, and in the third value, in the array it searches for 'ies', and replaces it with 'y'. To get around it, I simply declared the variable in my own controller for the edit view:

Controllers / series.php

Code: Select all

<?php

defined('_JEXEC') or die;

class SermonlibraryControllerSeries extends JControllerForm {
    protected $view_list = 'seriess';
}


That sorted it. Hopefully that'll make someone elses life a bit easier in the future. I suppose there must be a better way for me to name it, or perhaps unmarked plurals just aren't good words for class names

meejoo
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Nov 22, 2007 11:43 pm

Re: Incorrect list view being called from edit view

Postby meejoo » Tue Jun 27, 2017 6:37 pm

Hi there,

thanks that you posted it here.

Greetings,

m

kalinma
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Wed Jul 22, 2009 2:59 pm

Re: Incorrect list view being called from edit view

Postby kalinma » Thu Oct 05, 2017 10:17 pm

Thanks for posting this. I could not find where to configure the list view, but saw your line of code above in the controller for the edit view. That did it! Thanks again.

galihegacom
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Oct 06, 2017 8:34 am

Re: Incorrect list view being called from edit view

Postby galihegacom » Fri Oct 06, 2017 8:41 am

nice info thanks for this , i solved my problem
<a href="http://goseha.[URL banned].co.id">goseha</a>


Return to “Joomla! 3.x Coding”

Who is online

Users browsing this forum: No registered users and 3 guests