How do I get the node ID from the view's URL? I want to add a comment form to my view by using the following code:

print drupal_get_form('comment_node_project_form', array('nid' =&gt; $node-&gt;nid), 'comment');


However, it shows up a error saying that the variable $node->nid is undefined. I then realized it is a view, not a node.

In the view, by choosing the right URL, e.g. /projects/{username}/{nodeid}, I only show one content.

I guess I can get the node ID by parsing the 3rd argument of the URL. How do I get the node ID from the view's URL?
If the view uses fields, you can add a field labeled Content: Nid - and either build the link in the template by yourself or try to Rewrite the field in the Views admin UI. If the View uses display views, such as Teaser, you should be able to use the $node variable in the teaser (in this case) tpl file.