日历类中的查询字符串和下一个/上一个
How can I show the next/previous links in the calender when using query strings?
http://codeigniter.com/user_guide/libraries/calendar.html
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该相当简单,但并不像设置选项那么容易。
首先,请确保设置您的首选项,以便将“show_next_prev”设置为 true,并将“next_prev_url”设置为您的日历所在的任何 URL。确保您没有在 URL 末尾添加任何内容,例如斜杠或问号等。
其次,为了不破坏核心库文件,请创建一个名为 MY_Calendar 的新类并将其放置在您的应用程序/库文件夹中。使此类扩展 Calendar 类。
接下来,将原始 Calendar 类中的generate() 函数复制并粘贴到新的 MY_Calendar 类中。我们现在可以编辑此函数,它将覆盖而不删除原始函数。
找到在 next_prev_url 变量中添加尾部斜杠的行(大约第 163 行)并将其删除。
再往后几行,您将看到:
将此行替换为:
然后在几行后对 next_url 执行完全相同的操作。它应该位于第 183 行附近,并且看起来非常相似。
应该就是这样。您所做的就是确保为下一个和上一个 url 生成的语法与查询字符串样式匹配。
请注意,我还没有测试过这个,但它应该有效!
This should be fairly straightforward, but it's not as easy as setting an option.
Firstly, make sure you set your preferences so that the "show_next_prev" is set to true and set the "next_prev_url" to whatever URL you have your calendar at. Make sure you don't put anything at the end of the URL eg a slash or question mark etc.
Secondly, so as not to hack a core library file create a new class called MY_Calendar and place it in your application/library folder. Make this class extend the Calendar class.
Next copy and paste the generate() function from the original Calendar class into your new MY_Calendar class. We can now edit this function and it will overwrite without removing the original.
Find the line (around line 163) where it a trailing slash is added the the next_prev_url variable and delete it.
A few lines further on you will see:
Replace this line with:
Then do exactly the same a few lines later for the next_url. It should be around line 183 and will look very similar.
And that should be it. All you've done is made sure the syntax that is generated for the next and prev urls matches the query string style.
Please note, I haven't tested this, but it should work!