从视图名称获取视图 ID
我试图通过提供视图的名称来获取视图的 id。现在我必须将视图插入节点,然后使用 dsm 检查它以查看其 ID,然后在需要的地方进行硬编码。这不是一个好的工作流程。如果至少我可以获取视图的 ID,而无需先将其插入某处并使用 dsm 检查它,那就更好了。我尝试从视图列表中查找视图的 ID,但在任何地方都看不到它,我看到的只是视图的名称。
有没有办法从视图界面获取 ID,或者通过根据名称加载视图,然后检查其 ID 以编程方式获取 ID。但我对后一个选项的担忧是,我不想仅仅为了读取 ID 而加载和渲染视图,从而给页面带来负担。我不知道那会有多重。
I'm trying to get the id of a view by supplying its name. Right now I have to insert the view into a node, then inspect it with dsm to see its ID, which I then hardcode where I need it. That's not a good workflow. If at least I could get the view's ID without inserting it somewhere first and inspecting it with dsm, that would be better. I tried finding the view's ID from the views list, but couldn't see it anywhere, all I see is the view's name.
Is there a way to get the ID from the views interface or programmatically by loading the view based on its name, then checking its ID. But my concern with the latter option is that I don't want to burden the page with loading and rendering the view just to read the ID. I don't know how heavy that would be.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
视图会自动生成一些类名,但您不会被迫使用它们,如果您自定义视图模板,则可以排除它们。
但是,在顶部 div 包装器上,您将获得可以使用的类名称:
该名称是视图内部使用的名称,无论您在创建它时给它什么,只有
_
将替换为-
如果您要查找的是
vid
,您可以在view_views
表中找到它。您可以使用上面提到的名称来获取它。Views auto generate some class names, but you are not forced to use them and if you customize views template you can exclude them.
However, on the top div wrapper, you will get class names that you can use:
The name is what views used internally, whatever you gave it when you created it, only
_
will be replaced with-
If it's the
vid
you are after, you can find it in theview_views
table. You can use the above mentioned name to get it.