脚本宝典收集整理的这篇文章主要介绍了php – 将一个表暴露给Views,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试使用the table wizard module,但它只是为该表创建一个单独的视图.我希望能够从该表中选择要添加到现有视图中的字段作为附加字段,或通过关系或类似的东西.是否有解决方法来做我想做的事情?
function modulename_views_api() { return array( 'api' => 2,); }
然后你想创建一个名为modulename.views.inc的文件并定义一个这样的函数:
function modulename_views_data() { $data['modulename_table'] = array( 'table' => array( 'group' => 'ModuleName','tITle' => 'Module name title',),'join' => array( // to join to node,we'll use a field in modulename_table called 'nid' 'node' => array( 'left_field' => 'nid','field' => 'nid',); // Now we define the fields in the table like this // check out modules/views/handlers to see more sPEcific handlers $data['modulename_table']['fieldname'] = array( 'title' => 'fieldname','help' => 'fieldname description','field' => array( 'handler' => 'views_handler_field',); $data['modulename_table']['nid'] = array( 'title' => 'related node','help' => 'the field that relates back to {node}',// here we implement a relationship to nid 'relationship' => array( 'base' => 'node','field' => 'nid','handler' => 'views_handler_relationship','label' => 'modulename row node',// this relationship can be turned on in views ); return $data; }
以上是脚本宝典为你收集整理的php – 将一个表暴露给Views全部内容,希望文章能够帮你解决php – 将一个表暴露给Views所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。