简体   繁体   English

CodeIgniter Campaign最佳实践

[英]CodeIgniter Campaign Best Practice

I've got what I think is a simple problem but I'm having a tough time working out what the best strategy is and I hoping you could help. 我认为这是一个简单的问题,但我很难找到最好的策略,我希望你能提供帮助。

I'm using CodeIgniter to build my new website (currently in dev), where users are able to create, edit and delete campaigns. 我正在使用CodeIgniter构建我的新网站(目前在开发中),用户可以在其中创建,编辑和删除广告系列。 And each campaign has a sub-campaign which the can also edit, delete and create each sub-campaign. 每个广告系列都有一个子广告系列,也可以编辑,删除和创建每个子广告系列。

Whilst in the add campaign view, how do I (in pseudo code) mark the form (or session in a way where the sub campaign the user is creating gets assigned to the correct campaign. My thoughts at the moment are to either 在添加广告系列视图中,我如何(在伪代码中)标记表单(或以用户创建的子广告系列的方式将会话分配给正确的广告系列。我此刻的想法是

(1) Use the id of the campaign within the url and pull the correct segment. (1)在网址中使用广告系列的ID并拉出正确的细分。 For example http://www.website.com/campaign/ 12345 /add-sub-campaign 例如http://www.website.com/campaign/ 12345 / add-sub-campaign

or 要么

(2) Inside the form element put the name of the campaign in a hidden input field, and grab that through the post and use that to link the new sub-campaign to the campaign. (2)在表单元素中,将广告系列的名称放在隐藏的输入字段中,然后通过帖子抓取该名称,并使用该名称将新的子广告系列链接到广告系列。

Thanks for your help with this tedious question! 感谢您对这个乏味的问题的帮助! I'd prefer just to do it the right way first time. 我宁愿第一次以正确的方式做到这一点。

You can use a URL schema like example.com/campaigns/add/234 您可以使用URL架构,例如example.com/campaigns/add/234

Here 234 is the parent campaign ID 这里234是父活动ID

In your Campaign controller 在您的Campaign控制器中

public function add($parent_id = ''){ //......}

This saves you from using hidden field in the form as well 这样您也可以避免在表单中使用隐藏字段

I think you should use a hidden form input eg id of campaign you are assigning under. 我认为您应该使用隐藏的表单输入,例如您正在分配的广告系列的ID。

If you use url segments, it can create such problems in a way that id of segment is changed by user and campaign is assigned to totally different one. 如果您使用网址细分,则可能会产生此类问题,即用户更改细分ID并将广告系列分配给完全不同的细分。 (User changes website.com/campaign/12345/add-sub-campaign into website.com/campaign/54321/add-sub-campaign ) Plus, url segmentation could make you check more about what user doing. (用户将website.com/campaign/12345/add-sub-campaign更改为website.com/campaign/54321/add-sub-campaign )另外,网址细分可以让您更多地了解用户在做什么。 Is id from url segment valid or not etc. 来自网址段的ID是否有效等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM