如何将新视图添加到现有的joomla 3.x组件

时间:2016-09-02 17:23:37

标签: php sql joomla

我正在尝试添加“spsoccer”joomla组件的新视图(称为lista)。 我跟着这个post但是我遇到了以下错误:

 "1146
Table 'labaitac5.#__spsoccer_lista' doesn't exist SQL=SHOW FULL COLUMNS FROM `#__spsoccer_lista`"

这就是我所做的:

我复制了另一个视图的结构(称为锦标赛)

所以现在我有:

directory structure

我使用适当的类更改了Lista文件夹中的view.html.php:

<?php
 class SpsoccerViewLista extends FOFViewHtml{
    public function display($tpl = null){
    // Get model
    $model = $this->getModel();
    // get item
    $this->item = $model->getItem();

    //Joomla Component Helper & Get LMS Params
    $app                = JFactory::getApplication();
    $menuItem           = $app->getMenu()->getActive();
    $this->show_group   = $menuItem->params->get('show_group', 1);

    // Get last played match
    $this->last_played_match = $model->getLastPlayedMatch($this->item->spsoccer_tournament_id);
    $this->match_banner = (!empty($this->last_played_match->image)) ? 'style="background-image: url(' . $this->last_played_match->image . ')"' : '' ;

    // get groups of this tournament
    $this->groups   = $model->getTournamentGroups($this->item->spsoccer_tournament_id);

    foreach ($this->groups as $this->group) {
        $this->group->title = (strpos($this->group->slug, 'uncategory') !== FALSE) ? JText::_('COM_SPSOOCER_GROUP') : $this->group->title;
        $this->group->ungroup = (strpos($this->group->slug, 'uncategory') !== FALSE) ? 'ungroup' : '';
    }

    // Get Sessions by Tournament ID
    $this->sessions = $model->getTournamentSessions($this->item->spsoccer_tournament_id);

    // Get Matches By Session and Tournament 
    foreach ($this->sessions as &$this->session) {
        $this->session->session_matches = $model->getSessionMatches($this->session->spsoccer_session_id, $this->item->spsoccer_tournament_id);

        $this->session->title = (strpos($this->group->slug, 'uncategory') !== FALSE) ? JText::_('COM_SPSOOCER_SESSION') : $this->session->title;

        foreach ($this->session->session_matches as &$this->session->session_match) {
            //Get team one info
            $this->session->session_match->team_one_info = $model->getTeamInfoById($this->session->session_match->teamone);

            $this->session->session_match->team_one_url = JRoute::_('index.php?option=com_spsoccer&view=gameteam&id=' . $this->session->session_match->team_one_info->spsoccer_gameteam_id . ':' . $this->session->session_match->team_one_info->slug . SpsoccerHelper::getItemid('gameteams'));

            //Get team two info
            $this->session->session_match->team_two_info = $model->getTeamInfoById($this->session->session_match->teamtwo);

            $this->session->session_match->team_two_url = JRoute::_('index.php?option=com_spsoccer&view=gameteam&id=' . $this->session->session_match->team_two_info->spsoccer_gameteam_id . ':' . $this->session->session_match->team_two_info->slug . SpsoccerHelper::getItemid('gameteams'));

            //Match Date
            $this->session->session_match->match_date = JHtml::date($this->session->session_match->date, 'd M Y');
            //Match Month
            $this->session->session_match->match_time = date ('H:i',strtotime($this->session->session_match->time));
            //Match Location
            $this->session->session_match->match_location = $model->getVanueInfoById($this->session->session_match->spsoccer_vanue_id);


        } //END:: $this->session->session_matches

        //Get Sessions Played Match
        $this->session->played_matches = $model->getSessionPlayedMatches($this->session->spsoccer_session_id, $this->item->spsoccer_tournament_id);

        foreach ($this->session->played_matches as &$this->session->played_match) {

            // Generate Match URL
            //$this->session->played_match->team_one_info = $model->getTeamInfoById($this->session->played_match->teamone);
            $this->session->played_match->url = JRoute::_('index.php?option=com_spsoccer&view=match&id=' . $this->session->played_match->spsoccer_match_id . ':' . $this->session->played_match->slug . SpsoccerHelper::getItemid('matches'));

            //Get team one info
            $this->session->played_match->team_one_info = $model->getTeamInfoById($this->session->played_match->teamone);

            $this->session->played_match->team_one_url = JRoute::_('index.php?option=com_spsoccer&view=gameteam&id=' . $this->session->played_match->team_one_info->spsoccer_gameteam_id . ':' . $this->session->played_match->team_one_info->slug . SpsoccerHelper::getItemid('gameteams'));

            //Get team two info
            $this->session->played_match->team_two_info = $model->getTeamInfoById($this->session->played_match->teamtwo);

            $this->session->played_match->team_two_url = JRoute::_('index.php?option=com_spsoccer&view=gameteam&id=' . $this->session->played_match->team_two_info->spsoccer_gameteam_id . ':' . $this->session->played_match->team_two_info->slug . SpsoccerHelper::getItemid('gameteams'));

            //Match Date
            $this->session->played_match->match_date = JHtml::date($this->session->played_match->date, 'd M Y');
            //Match Month
            $this->session->played_match->match_time = date ('H:i',strtotime($this->session->played_match->time));
            //Match Location
            $this->session->played_match->match_location = $model->getVanueInfoById($this->session->played_match->spsoccer_vanue_id);

        }

    } // END:: foreach $this->session->session_matches

    // Team Standings

    // $this->teams_ids = array();
    // foreach ($this->groups as $this->group) {
    //  $group_team_ids = json_decode($this->group->spsoccer_gameteam_id);
    //  foreach ($group_team_ids as &$group_team_id) {
    //      $this->teams_ids[] = $group_team_id;
    //  }   
    // }
    // $this->uniqie_teams_ids = array_unique($this->teams_ids);

    // // Team info
    // $this->unique_team_info = array();

    // foreach ($this->uniqie_teams_ids as $this->uniqie_teams_id) {
    //  $this->unique_team_info[] = $model->getTeamInfoById($this->uniqie_teams_id);
    //  //print_r($this->team_info);
    // }


    // Point Table


    foreach ($this->groups as &$this->sgroup) {
        //title
        $this->sgroup->uncategory = (strpos($this->group->slug, 'uncategory') !== FALSE) ? 'uncategory' : '';

        // Get Timeline
        $point_table_decode     = json_decode($this->sgroup->point_table);

        if ($point_table_decode) {
            // Point table
            $teams      = $point_table_decode->team;
            $playeds    = $point_table_decode->played;
            $wons       = $point_table_decode->won;
            $draws      = $point_table_decode->draw;
            $losts      = $point_table_decode->lost;
            $gforwards  = $point_table_decode->gforward;
            $gagainsts  = $point_table_decode->gagainst;
            $avgs       = $point_table_decode->avg;
            $ptss       = $point_table_decode->pts;

            $point_tables = array();
            $pt_key = 0;
            foreach ($teams as $id => $team) {
                $team_info  = $model->getTeamInfoById($teams[$id]);
                $team_title = $team_info->title;
                $team_logo  = $team_info->logo;


                $point_tables[$pt_key] = array(
                    'team_name' => $team_title,
                    'team_logo' => $team_logo,
                    'plays'     => $playeds[$id],
                    'wons'      => $wons[$id],
                    'draws'     => $draws[$id],
                    'losts'     => $losts[$id],
                    'gforwards' => $gforwards[$id],
                    'gagainsts' => $gagainsts[$id],
                    'avgs'      => $avgs[$id],
                    'ptss'      => $ptss[$id],
                );

                $pt_key ++;
            }

            $this->sgroup->point_tables = $model->msort($point_tables, array('ptss'));

        } // END:: has point table

    } // END:: foreach $this->groups



    // Match Location
    $this->match_location = $model->getVanueInfoById($this->item->spsoccer_tournament_id);



    return parent::display($tpl = null);
}
}

有人可以帮帮我吗?

0 个答案:

没有答案