How do you correctly pass and validate a Node: Type argument in Views 2?

I have several content types, 1 for each U.S. city. I'd like to generate a view based on the node type (ex. New York, Boston, etc. passed in the URL.
Currently the functionality works by selecting "Node: Type" under Arguments, title "You're in %", "Hide View" if argument is not present, basic validation, and "Hide View" if the argument does not validate.

The view works fine when ever I type in a URL with the correct city name and node type (cities/newyork). The title says "You're in New York" and the view shows up underneath. However, when I type in an incorrect URL, the title reads "You're in Unknown node type" and obviously no view appears.

How do I validate the node type and return 404 if an incorrect URL or node type is entered?

Comments

dawehner’s picture

The best thing is to use the code, below to use in a argument validation plugin.

<?php
$types = node_get_types();
if ($argument) {
  return isset($types[$argument]);
}
return FALSE;
?>
esmerel’s picture

Status: Active » Closed (fixed)

Solution provided, no response.

esmerel’s picture

Solution provided, no response.