我又一次迷失了方向。我要从这件事开始,因为我甚至不确定我到底想要什么。
示例:我有一篇文章视图。URL是:http://index.php/news/article/3
这实际上是在我的news
控制器中运行article($id)
函数,并将3
作为参数,然后该函数获取文章信息并将其显示在视图中。
在文章页面上,用户也可以登录。登录是在我的表单form_open('core/login')
... button... </form>
中按提交按钮触发的。在函数中,我登录用户,并根据登录的用户更改了一些元素来刷新当前视图。问题是,URL现在是http://index.php/core/login
。显然,我希望它是原始的URL。
有什么可能简单的解决办法来实现这一点吗?感谢大家的阅读和提前回复。
2条答案
按热度按时间aurhwmvo1#
没有更多的代码很难,但让我给予你我的理论/采取这一点:
默认控制器:
1.用户未登录-显示默认页眉、内容、页脚
1.用户按下登录,显示表格
1.用户已通过身份验证-是(继续)否(返回表单)
1.用户被重定向('home')'d
1.默认控制器/主控制器检查是否已授权:如果被授权,则显示已登录的页眉、内容和页脚,或者简单地将'loggedIN'作为$data ['loggedIN']变量传递给视图-但这打破了MVC框架的思想。
更多的信息,从你我可以更具体,或者我们可以谈谈IRC。
从我现在正在使用的控制器添加此代码-我使用ion_auth库(您应该查找它,它非常出色)。
这是我的默认控制器-正如您所看到的,一些简单的逻辑加载了不同的视图/状态。
下面是我在登录函数中处理返回URL的方法:登录/身份验证控制器:(使用ion_auth)
这只是登录函数的一个摘录/片段-但正如你所看到的,我利用代码触发器中的函数“redirect”将用户推回到登录表单中发布的返回URL(该URL是在视图/前一个控制器中使用current_url()函数设置的)。
最后我的默认视图文件与登录表单,以显示您我是如何传递返回URL:
6tqwzwtp2#
要将当前动态url用作表单操作,只需使用-