Drupal - Get View Display Id

Kevin's picture

[b]Q:[/b] How do I get the 'display id' ($display_id) of a view display so that I can pass it to views_embed_view() when programmatically showing a view?

[b]A:[/b] View display ids follow a pattern like page_1, page_2, block_1, block_2 etc., depending on the display type - they do not follow the display's title (I spent a lot of time trying to plug in variations of the display name with no success!) The documentation for views_embed_view() does not explain what the display id is or where it comes from....

There is a simple way to figure out what it is. Navigate to your view in the Views UI, make sure your display is active by clicking on it and then hover your mouse over one of its settings (for example, its title) - the display id will now be displayed at the bottom of the browser as part of the link url, for example:

[img]http://www.pridedesign.ie/sites/default/files/images/display_id.png[/img]

Here 'page_1' is the display id and can be passed to
views_embed_view() as follows:


print views_embed_view('user_horses', 'page_1');

So, you can either get it this way, or just guess it if you manage to remember the page_1, page_2, block_1, block_2...... pattern (which I can never do even though it's very simple!).

Share this post: 

Recent Work

Some of Ireland's biggest brands use Pride Design to Design, Build, Manage, Market and Maintain their websites.

Website design for St.Patricks Credit Union in Dublin, Including Loan Calculators.

Website design and development for a step by step wedding and other stationary ordering website f

New website designed and developed for Cork's newest café, which is based in Merchants Quay in Co

New Website design for Pain Relief clinic based in Cork City.

Website for a busy Dublin city centre pub.

We redrafted the Ballymaloe house website to modernise the look and feel of the site and to also

We revamped the website for the Ballymaloe Cookery School.

We revamped the Cully & Sully website onto Drupal.

Rachel Allen was brought up in Dublin and left home at eighteen to study at the world-famous Ball

Clóna Dairy Products are a Dairy Company based in Clonakilty, Co. Cork, since 1919.

Project Arts Centre is Ireland’s leading centre for the presentation and development of c