开发者

drupal argument problem using views

开发者 https://www.devze.com 2023-02-27 08:27 出处:网络
Say you have two content types, restaurant and menu. The restaurant content type has various CCK fields like id, address etc. While Menu has a node reference to restaurant and other CCK fields like br

Say you have two content types, restaurant and menu. The restaurant content type has various CCK fields like id, address etc. While Menu has a node reference to restaurant and other CCK fields like breakfast, lunch etc. I know I can easily display the fields of Menu using Views however, what I would really like to achieve is use the id of restaurant as an argument in a page view.

I have attempted this by creating the page view, added the event id as an argument (I selected the default action and added PHP snippet below), and added fields from the m开发者_Python百科enu but I get no result. Something does not seem quite right but unsure of what it is.

if(arg(0)== restaurant  && arg(1) !='') return arg(1); 

The reason why I am passing an argument is because I have got quite a number of restaurants which have their respective id’s and with different menu’s, so if I got to a particular url with the id as specified above, it should show the relating menu


I am guessing your php snippet never gets invoked. Views would invoke the snippet only if it couldn't find the argument in the url. But if the url looks like '...mypage/restaurant/371', then views grabs 'restaurant' as your argument. Because the argument was found within the url, the php snippet is not invoked.

Perhaps you could drop the 'restaurant' keyword, and pass just the restaurant-id in the url.

0

精彩评论

暂无评论...
验证码 换一张
取 消