【问题标题】:CodeIgniter Calendar Library: URLs appended to end of current URLCodeIgniter 日历库:附加到当前 URL 末尾的 URL
【发布时间】:2013-06-23 17:50:31
【问题描述】:

我(有点)是 Web 开发新手(主要是桌面开发人员),在使用 CodeIgniter 时遇到了问题,它是日历库。

我的问题是,当我生成日历时,我传递给函数的 URL 被附加到他当前 url 的末尾!以下是相关代码:

//链接生成代码

//Get numbers of days in month
        $day_count = cal_days_in_month(CAL_GREGORIAN, $month, $year);

        //For each day of the month, check for appointments
        for($i = 1; $i <= $day_count; $i++)
        {
            //Create date array
            $date = array
            (
                    'year' => $year, 
                    'month' => $month, 
                    'day' =>$i
            );


            if ($this->appointment_model->get_appointment_dates($date))
            {
                //If there is an appointment, add link
                $appointment_data[$i] = 'view_day'. '/' . $year . '/' .$month;
            }
        }

//日历模板

        $calendar_template ='

       {table_open}<table border="1" cellpadding="0" cellspacing="0">{/table_open}

       {heading_row_start}<tr>{/heading_row_start}

       {heading_previous_cell}<th><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}
       {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
       {heading_next_cell}<th><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}

       {heading_row_end}</tr>{/heading_row_end}

       {week_row_start}<tr>{/week_row_start}
       {week_day_cell}<td>{week_day}</td>{/week_day_cell}
       {week_row_end}</tr>{/week_row_end}

       {cal_row_start}<tr>{/cal_row_start}
       {cal_cell_start}<td>{/cal_cell_start}

       {cal_cell_content}<a href="index.php/calendar/{content}/{day}">{day}</a>{/cal_cell_content}
       {cal_cell_content_today}<div class="highlight"><a href="index.php/calendar/{content}/{day}">{day}</a></div>{/cal_cell_content_today}

       {cal_cell_no_content}{day}{/cal_cell_no_content}
       {cal_cell_no_content_today}<div class="highlight">{day}</div>{/cal_cell_no_content_today}

       {cal_cell_blank}&nbsp;{/cal_cell_blank}

       {cal_cell_end}</td>{/cal_cell_end}
       {cal_row_end}</tr>{/cal_row_end}

       {table_close}</table>{/table_close}
    ';

包含日历的url如下:

http://localhost:8888/AI_Project/index.php/calendar/view_appointments/2013/06

添加到日历中的链接如下所示:

http://localhost:8888/AI_Project/index.php/calendar/view_appointments/2013/index.php/calendar/view_day/2013/06/18

我不确定这是为什么。任何帮助,将不胜感激。如果您还需要其他任何东西,请告诉我!

谢谢!

【问题讨论】:

    标签: php codeigniter url


    【解决方案1】:

    请到config/config.php找到这个变量

    $config['index_page'] = 'index.php' 确保它看起来像这样 $config['index_page'] = '';

    在同一个文件中找到$config['base_url'] = '';,确保它看起来像这样

    $config['base_url'] = 'http://localhost:8888/AI_Project/';

    还在核心文件夹(系统、应用程序所在的位置)中创建 .htaccess 文件并确保它看起来像这样

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /AI_Project
    
        #Removes access to the system folder by users.
        #Additionally this will allow you to create a System.php controller,
        #previously this would not have been possible.
        #'system' can be replaced if you have renamed your system folder.
        RewriteCond %{REQUEST_URI} ^system.*
        RewriteRule ^(.*)$ /index.php?/$1 [L]
    
        #When your application folder isn't in the system folder
        #This snippet prevents user access to the application folder
        #Submitted by: Fabdrol
        #Rename 'application' to your applications folder name.
        RewriteCond %{REQUEST_URI} ^application.*
        RewriteRule ^(.*)$ /index.php?/$1 [L]
    
        #Checks to see if the user is attempting to access a valid file,
        #such as an image or css document, if this isn't true it sends the
        #request to index.php
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        # If we don't have mod_rewrite installed, all 404's
        # can be sent to index.php, and everything works as normal.
        # Submitted by: ElliotHaughin
    
        ErrorDocument 404 /index.php
    </IfModule>
    

    【讨论】:

    • 您好,感谢您的解决方案!不幸的是,这并没有解决我的问题。不过还是谢谢你!
    猜你喜欢
    • 2012-06-20
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-23
    相关资源
    最近更新 更多