views:

37

answers:

1

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.

+2  A: 

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:

  • view-[name]
  • view-id-[name]

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 the view_views table. You can use the above mentioned name to get it.

googletorp
I should clarify. I know the name. What I'm trying to get is the view ID which is a number.
Berming
The table views_view doesn't contain the ID of any default view; I activated different views, but in the table I see just one ID, which refers to a modified view.
kiamlaluno
@kiamlaluno Default views don't have vids, because they are defined in code. I should note I'm still uncertain what id OP wants and what he wants to use it for. The view name should be all he needs.
googletorp