简体   繁体   English

Grocery Crud:如何根据URL为自定义视图标识ID?

[英]Grocery Crud: How to identify ID based on URL for custom view?

I needed to create a custom view in grocery crud, so I have an add_action that brings the user to a file called pastMenuPrint.php . 我需要在杂货杂货店中创建一个自定义视图,所以我有一个add_action ,它将用户带到一个名为pastMenuPrint.php的文件中。

I am having trouble coding something that will take the url and determine what id it should look up. 我在编写将采用url并确定应查找的id代码时遇到了麻烦。

Example. 例。 .../scripts/pastMenuPrint.php/2 should look up the past menu for the id of 2 . .../scripts/pastMenuPrint.php/2应该在过去的菜单中查找id2菜单。

Is there any way to do that? 有什么办法吗? I am very new to coding and grocery crud, so please keep it simple if you can! 我是编码和杂货杂货开发人员的新手,所以请尽量保持简单!

When you hover action button on some row in crud table the url where that actions leads should appear in the bottom left of your browser and looks something like /foo/bar/345 345 is id of that row in your table, so function that does your magic in pastMenuPrint.php must receive $id 当您将操作按钮悬停在Crud表中的某行上时,该操作导致的URL应该出现在浏览器的左下角,并且看起来像/foo/bar/345 345是表中该行的ID,因此执行该操作的函数您在pastMenuPrint.php中的魔力必须获得$ id

That will look something like this 看起来像这样

function printMenu($id){

That should do the trick, I hope that helps, good luck! 那应该可以解决问题,希望对您有帮助,祝您好运!

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

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