简体   繁体   English

在Modx中包装Wayfinder菜单:如何传递所有变量(也许是一般的PHP问题)

[英]Wrapping Wayfinder Menu in Modx: How to pass all vars (general PHP question, perhaps)

I have made a tiny ModX snippet that looks like this 我做了一个很小的ModX片段,看起来像这样

<?php
$theMenu = $modx->runSnippet('Wayfinder',
 array("startId" => 0, "level"=>1)
);
echo $theMenu;
?>

but I would like it to pass ALL params it receives to Wayfinder. 但我希望它将接收到的所有参数传递给Wayfinder。 I will only be modifying the "level" parameter from my snippet. 我只会从代码段中修改“级别”参数。

Is there any way, without naming all the relevant variables individually, to cycle through all the currently SET variables in PHP? 有没有办法单独命名所有相关变量,以循环浏览PHP中的所有当前SET变量?

Edit : I don't think that get_defined_vars is the right way to go, as it gets too much stuff. 编辑 :我不认为get_defined_vars是正确的方法,因为它得到了太多的东西。 This trivial PHP page prints out the number 14, for instance: 这个琐碎的PHP页面打印出数字14,例如:

<?php
echo count(get_defined_vars()); 
?>

This might be useful: get_defined_vars() ? 这可能很有用: get_defined_vars()

Edit 编辑

From http://bobsguides.com/modx-snippet-faq.html : http://bobsguides.com/modx-snippet-faq.html

You can also access the parameters via the associative array $modx->event->params. 您也可以通过关联数组$ modx-> event-> params访问参数。

尝试使用foreach自动将参数分配给Wayfinder对象

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

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