Display block based on main content type with view I have created a view in a block, to display some related information to the current content type being displayed into the block. More precisely, I want to display the block only for book pages.

What I did is to add a contextual filter based on content type. 
For "WHEN THE FILTER VALUE IS NOT AVAILABLE", I provide a default value for "PHP contextual filter code" as follows

$node = node_load(arg(1));
return $node-&gt;type;


For "WHEN THE FILTER VALUE IS AVAILABLE", I use "Specify validation criteria" for content types with "book page".

I tried this but it didn't work. I think because I am using aliases in the url, it does not work.

What am I missing?

P.S: My final goal is actually to extract the group audience from the current book page and display the admins of that group into the block.
In your case you don't need to provide any default value with PHP code.

Remove your contextual filter and add new one: Content: nid.

"WHEN THE FILTER VALUE IS NOT AVAILABLE" 

Provide default value -> content ID from URL

"When the filter value IS available or a default is provided" 

Specify validation criteria

Validator -> Content -> book