CodeIgniter日历库:附加到当前URL结尾的URL [英] CodeIgniter Calendar Library: URLs appended to end of current URL
问题描述
我是(排序)新的web开发(大多是桌面开发人员),并遇到了问题使用CodeIgniter,它是日历图书馆。
我的问题是,当我生成日历,我传递给函数的URL附加到当前url的结尾!以下是相关代码:
//链接生成代码
//获取月份天数
$ day_count = cal_days_in_month(CAL_GREGORIAN,$ month,$ year);
//对于每月的每一天,检查约会
for($ i = 1; $ i <= $ day_count; $ i ++)
{
//创建日期数组
$ date = array
(
'year'=> $ year,
'month'=> $ month,
' day'=> $ i
);
if($ this-> appointment_model-> get_appointment_dates($ date))
{
//如果有约会, $ b $ appointment_data [$ i] ='view_day'。 '/'。 $ year。 '/'。$ month;
}
}
//日历模板
$ calendar_template ='
{table_open}< table border =1cellpadding =0cellspacing =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} b $ b {cal_row_end}< / tr> {/ cal_row_end}
{table_close}< / table> {/ table_close}
'
包含日历的网址如下:
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
我不知道为什么会这样。任何帮助将不胜感激。
谢谢!
请转到 config / config.php
并找到此变量
$ config ['index_page'] ='index.php'
确保它看起来像这样 $ config ['index_page'] ='';
/ p>
在同一个文件中查找 $ config ['base_url'] ='';
/ p>
$ config ['base_url'] ='http:// localhost:8888 / AI_Project /';
p>
也在核心文件夹(系统,应用程序)中创建.htaccess文件,并确保它看起来像这样
< IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase / AI_Project
#Removes用户访问系统文件夹。
#另外,这将允许您创建一个System.php控制器,
#previously这是不可能的。
#'system'可以替换,如果你已经重命名您的系统文件夹。
RewriteCond%{REQUEST_URI} ^ system。*
RewriteRule ^(。*)$ /index.php?/$1 [L]
#当应用程序文件夹不是在系统文件夹
#此代码段阻止用户访问应用程序文件夹
#提交者:Fabdrol
#Rename'application'到您的应用程序文件夹名称。
RewriteCond%{REQUEST_URI} ^ application。*
RewriteRule ^(。*)$ /index.php?/$1 [L]
#检查用户是否尝试访问一个有效的文件
#s如一个图像或CSS文档,如果这不是真的,它发送
#request到index.php
RewriteCond%{REQUEST_FILENAME}! - f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php?/ $ 1 [L]
< / IfModule>
< IfModule!mod_rewrite.c>
#如果我们没有安装mod_rewrite,所有404的
#都可以发送到index.php,一切正常。
#提交者:ElliotHaughin
ErrorDocument 404 /index.php
< / IfModule>
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}"><<</a></th>{/heading_previous_cell}
{heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
{heading_next_cell}<th><a href="{next_url}">>></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} {/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!
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>
这篇关于CodeIgniter日历库:附加到当前URL结尾的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!