CodeIgniter 3重定向功能不起作用(CodeIgniter 3 redirect function not working)
我正在重新编码和更新我的CMS我已经在CI2工作到CI3,而在我的生活中我无法让我的重定向功能在CI3上为我工作。
除了重新设计我的模型之外,到目前为止,我的代码与我的CI2代码完全相同。 本来我怀疑我的布局钩子是罪魁祸首,但我完全禁用了他,我仍然没有到达任何地方。
public function login () { //var_dump(logged_in()); //if (logged_in()) redirect('/user/'); }
以上是我的用户控制器当前的整个登录功能。 为了找出这个问题,我已经删除了所有其他代码。 我甚至评论过
if
语句,认为它甚至可能是罪魁祸首。 不。我的
logged_in()
函数返回TRUE或FALSE,具体取决于我的用户会话中设置的某些内容。 这似乎运作正常。 据我所知,我的配置设置看起来不错。 我有自动加载的URI帮助程序,其他URI帮助程序方法正常运行。现在为了奇怪的部分。 当我访问/ user / login时,不仅我的页面没有重定向,如果我在重定向之前取消注释
var_dump()
(返回true),并重新评论它,页面不会更新,我有bool(true)
在我的屏幕上无论如何。 如果var_dump
被注释,我打开一个新的选项卡给users/login
它根本不加载任何东西,它只是挂起作为一个新的选项卡。编辑 :我忘了提到当我使用'refresh'标志(
redirect('/user/', 'refresh');
),这只是带我到about:空白页面。编辑#2 :我已经将CI3文件复制到一个新的“项目”中,甚至那些不会使用内置的Welcome_Message视图/控制器组合重定向。
I'm in the process of re-coding and updating my CMS I've got working in CI2, to CI3, and for the life of me I cannot get my redirect function to work for me on CI3.
Outside of redesigning my Models, my code thus far is is identical to my CI2 code. Originally I suspected my layout hook was the culprit, but I've completely disabled him and I'm still not getting anywhere.
public function login () { //var_dump(logged_in()); //if (logged_in()) redirect('/user/'); }
Above is the entirety of my login function at the moment, from my User controller. I've removed all the other code in an effort to pinpoint this problem. I've even commented out the
if
statement thinking that it might even by the culprit. nope.My
logged_in()
function returns TRUE, or FALSE, depending on certain things set in my user sessions. That appears to be functioning fine. As far as I can tell, my configs settings looks good. I have the URI helper autoloaded, and other URI helper methods function properly.Now for the strange part. When I visit /user/login, not only does my page not redirect, if I un-comment the
var_dump()
before the redirect (which returns true), and re-comment it, the page doesn't update, and I havebool(true)
on my screen regardless. If thevar_dump
is commented and I open a new tab tousers/login
it simply doesn't load anything, and it just hangs out as a new tab.Edit: I've forgotten to mention that when I use the 'refresh' flag (
redirect('/user/', 'refresh');
), that simply takes me to an about:blank page.Edit#2: I've copied the CI3 files into a new "project", and even those wont redirect using the built in Welcome_Message view/controller combo.
原文:https://stackoverflow.com/questions/33686117
最满意答案
我认为你有一个语法错误:
$(window).resize(checkSize);
应该$(window).resize(function(){ checkSize(); });
这种修正对我没有任何其他改变。
I think you have a syntax error:
$(window).resize(checkSize);
should be$(window).resize(function(){ checkSize(); });
That correction worked for me with no other changes.
相关问答
更多-
不,您不能,因为在媒体查询中,“媒体查询中的相对单位基于初始值,这意味着单位绝不会基于声明结果。 例如,在HTML中,'em'单位相对于'font-size'的初始值。“(Media Query spec,第6章单位 )。 font-size的初始值是medium ,它以浏览器相关的方式映射到物理大小(独立于您可以在CSS中设置的任何内容)。 结论取决于你如何设置字体大小。 如果您以像素为单位设置根元素的字体大小,则在媒体查询中使用像素也是合乎逻辑的,因为em的使用不会提供任何灵活性。 如果您将根元素的字体 ...
-
如果你对jquery感到满意,那么你可以试试这个: if($(window).width() > 600) //here instead of '600' you can give your required width { $('#container').delay(600).fadeIn('slow') } else { ...... } If you are comfortable with jquery then you can try this : if($(window).widt ...
-
这是因为大多数较新的Android手机根据设备不同而有点像480宽800高,所以您的手写方式,Android风景应该被平板电脑风景CSS拾取。 但我认为我遇到了类似的问题,没有拿起样式表,所以我添加了这一点,似乎一切工作...... 你有没有在你的样式表链接之上? That's because most newer android phones are something like 480 wide ...
-
这个问题有两个问题: 视口定义丢失 需要定义min-width和max-width以使此场景中的媒体查询起作用。 以下是一些详细的解释: 媒体查询中没有rule_override_based_on_min / max_width 。 也就是说,如果有2个媒体查询规则集,一个是(max-width: 1024px) ,另一个是(max-width: 768px) ,则不能保证内部规则(max-width: 768px)将覆盖规则inside (max-width: 1024px) - 当两个不同的媒体查询规则 ...
-
使用jquery进行媒体查询(Media query using jquery)[2022-09-07]
我认为Crossfire的建议可能是最好的。 只需根据条件向HTML标记添加一个类。 如果您正在寻找仅限JS的解决方案,则可以使用window.matchMedia 例如: if( a == 20) { window.matchMedia('screen and (max-width: 900px) and (min-width:500px)') { // some code } } if( a == 40) { window.matchMed ... -
似乎我错误地使用了min / max-width和min / max-device-width语句(它们彼此冲突),这在阅读StackOverflow上对此问题的接受答案后变得明显。 似乎min / max-width指的是目标显示区域大小,min / max-device-width指的是整个设备渲染区域(其屏幕)。 在这种情况下使用的正确CSS是: .box { width:100%; } @media screen and (min-width:480px) { .box { wi ...
-
浏览器可能会缓存包含这些媒体查询的整个CSS文件,但浏览器不会缓存CSS文件的特定部分。 所以要回答你的问题,是的,浏览器可能会缓存媒体查询的非活动部分,因为它可能(并且可能会)缓存整个CSS文件。 The browser might cache the entire CSS file that these media queries are contained in, but browsers do not cache particular sections of a CSS file. So to an ...
-
我认为你有一个语法错误: $(window).resize(checkSize); 应该 $(window).resize(function(){ checkSize(); }); 这种修正对我没有任何其他改变。 I think you have a syntax error: $(window).resize(checkSize); should be $(window).resize(function(){ checkSize(); }); That correction worke ...
-
不要操纵CSS display: property。 相反,使用CSS类来控制侧边栏及其句柄的可见性。 这样,您可以使用媒体查询来控制元素是否显示。 在下面的演示中,单击“整页”按钮以查看其在屏幕上的工作方式> 1160px。 $(function() { $('.right_sidebar, .right_preview').on('click', function() { $('.right_sidebar, .right_preview').toggleClass('lt-1160-h ...
-
你需要检查viewport的width ,如, function viewport() { var e = window, a = 'inner'; if (!('innerWidth' in window )) { a = 'client'; e = document.documentElement || document.body; } return { width : e[ a+'Width' ] , height : e[ a+'Hei ...