Drupal 6 Views 2 使用节点路径作为参数
请考虑帮助一个 Drupal 菜鸟,他有撕掉我剩下的头发的危险。
我有一个视图,我想添加一个参数,以便它只显示指定产品的详细信息。由于我使用 URL 别名,因此参数的形式为 shop/product1、shop/product2 等。但是,当我添加参数节点路径时(我设置为 shop/product1 等的路径未列出)我唯一可以使用的是 Node: Nid 但这不起作用,因为我的参数不是节点 id 而是路径别名。
我一直使用的解决方法是创建一个 CCK 字段来存储我的节点路径,然后使用 CCK 字段创建一个参数。这是唯一的选择吗?
问候,
肖恩
Please consider helping a Drupal noob who is in danger of tearing out what hair I have remaining.
I have a view that I want to add an argument to so that it only displays the details of the specified product. Since I'm using URL aliasing the argument is in the form of shop/product1, shop/product2 etc. However, when I go to add an argument node path (which is what I have set to shop/product1 etc is not listed) the only I could use is Node: Nid but that doesn't work because my argument is not a node id but a path alias.
The workaround I've been using is to create a CCK field to store my node path and then create an argument using the CCK field. Is this the only option?
Regards,
Sean
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种方法是创建一个自定义模块并定义您自己的回调,然后该回调将从路径计算出 NID 并使用 views_embed_view。
有一些 contrib 模块允许您通过 PHP 代码进行过滤,这可能也可以。
One way to do this would be to create a custom module and define your own callback which would then work out the NID from the path and pass that as an argument to the view using views_embed_view.
There are some contrib modules which allow you to filter by PHP code which would probably do as well.
我相信您仍然可以使用 NID 作为参数,因为即使您在地址栏中显示别名,这也是实际路径中的内容。
I believe you can still use NID as the argument, as that is what's in the actual path even though you are displaying an alias in the address bar.