CodeIgniter Calendar Library: URLs appended to end of current URL

北城以北 提交于 2020-01-07 07:43:11

问题


I'm (sorta) new to web development (Mostly a desktop developer) and have run into a problem using CodeIgniter, and it's Calendar Library.

My problem is, When I generate the calendar, the URLs I pass to the function are appended to the end of he current url! The following is the relevant code:

//Link Generating Code

//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

        $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}
    ';

The url containing the calendar is as follows:

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

And the links added to the calendar look like this:

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

I'm not sure why this is. Any help would be appreciated. Let me know if you need anything else either!

Thank you!


回答1:


Please go to config/config.php and find this variable

$config['index_page'] = 'index.php' make sure it looks like this $config['index_page'] = '';

in the same file find $config['base_url'] = ''; make sure it looks like this

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

Also in core folder (where system, application is) create .htaccess file and make sure it looks like this

<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>


来源:https://stackoverflow.com/questions/17322632/codeigniter-calendar-library-urls-appended-to-end-of-current-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!