codeigniter 额外的 url 段

发布于 2024-11-19 18:51:16 字数 613 浏览 1 评论 0原文

我正在为客户制作一个网站,并决定使用代码点火器。

该网站本质上有两个后端,一个用于设计师,另一个用于销售团队。因此,登录后,用户将被重定向到

  • mysite.com/sales/
  • mysite.com/design/

例如,销售团队可以查看订单、容器、产品,因此我需要为每一个提供一个控制器。

  • mysite.com/sales/orders/

销售人员需要能够查看、编辑、删除某些订单...

  • mysite.com/sales/orders/vieworder/235433

基本上我的问题是我没有足够的网址段可以使用。

我对解决问题的想法

  • 删除订单、容器、产品类并将它们的所有方法作为销售类的方法,尽管这意味着大量的方法并加载所有模型,所以它似乎毫无意义。

  • 删除销售/设计师类并根据会话数据中存储的用户类型控制每种用户有权访问的内容。

  • 一种拥有额外 url 段的方法?

我很感激任何建议,我只是不想在项目进行了三周后才意识到我从一开始就错了!

I am making a site for a client and decided i would use code igniter.

The site essentially has two backends, one for designers, and one for a sales team. So after logging in, the user will be redirected to either

  • mysite.com/sales/
  • mysite.com/design/

The sales team for example can view orders, containers, products, therefore i need a controller for each of these.

  • mysite.com/sales/orders/

The sales need to be able to view, edit, delete certain orders...

  • mysite.com/sales/orders/vieworder/235433

Basically my problem is i dont have enough url segments to play with.

My thoughts on solving my problem

  • removing the orders, containers, products classes and making ALL of their methods as methods of the sales class, although this would mean a large number of methods and loading all models so it seemed kind of pointless.

  • removing the sales/designer classes and controlling what each kind of user has access to based on a user type stored in session data.

  • a way of having an extra url segment?

I appreciate any advice, I just dont want to get 3 weeks into the project and realise i started wrong from the beginning!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

╄→承喏 2024-11-26 18:51:16

使用文件夹。

如果您在 /application/ 中创建一个名为 sales 的子文件夹,您可以在其中放置不同的控制器:

/application/
    /sales/
      orders.php /* Controller */
    /design/

然后在 orders.php 中您将放置您的 < code>vieworders($id) 方法等等,您将能够通过 domain.com/sales/orders/vieworders/id 访问它。

您还可以在 /models//views/ 中创建子文件夹来组织文件。

现在,访问控制是不同的,它更多地取决于您正在使用的身份验证系统。

Use folders.

If you make a subfolder in /application/ called sales you can put different controllers in there:

/application/
    /sales/
      orders.php /* Controller */
    /design/

Then in orders.php you will put your vieworders($id) method and so on, and you will be able to acces it with domain.com/sales/orders/vieworders/id.

You can also make subfolders in the /models/ and /views/ to organize your files.

Now, Access Control is something apart and it depends more in the auth system you are using.

十六岁半 2024-11-26 18:51:16

给用户/设计者一个权限,例如用户表中的一列,在函数的开头检查用户的权限,然后阻止或执行它。

这就是我要做的确切方式。

Give the user/designer a privilege, a column in the user table for example, check the permission of the user at the beginning of the function, then prevent or execute it.

This would be the exact way i would do it.

人间☆小暴躁 2024-11-26 18:51:16

看来你应该看看路由类。可能是一个肮脏的解决方案,但将 sales/(:any) 重新路由到 sales_$1 之类的内容意味着您将使用 sales_orders 之类的名称创建控制器。
设计部分也是如此。

(仅供参考:$routing['sales/(:any)'] = 'sales_$1'; 应该可以解决问题;请参阅 application/config/routing.php)。

Seems like you should have a look into the routing class. Might be a dirty solution but rerouting the sales/(:any) to something like sales_$1 would mean you'd make controllers with names like sales_orders.
Same for the design part.

(FYI: $routing['sales/(:any)'] = 'sales_$1'; should do the trick; see application/config/routing.php).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文