Contemplate - Embedded View Suggestions?

stangslvr - October 21, 2009 - 20:15

I have a site with magazine content on it. I have two content types within this example, an "issue" and a "story" or article. With my body contemplate file for my "story" content type i have an embedded view that displays all the other articles from the same "issue" date. In other words if a magazine was published on 9-16-09 then the issue would be created for 9-16-09 and all articles/"stories" uploaded to the site using the same date would be attached to this issue.
The date is passed into my embedded view through arguments to make this all happen. It works perfectly for this purpose...but one MAJOR problem. I dont have a validation code or if statement to protect the "story" output if the embedded view fails. This happens with a "story" gets uploaded to a date in which an issue has not been created. Can somebody please tell me some code to validate the view with the arguments before its run and kills my page?

I receive the page not found error on stories with dates that dont match an issue date.
I was hoping it was a easy if statement but cant seem to figure it out. If this view with this argument returns dead, then return nothing. If it works, then use this code... Make sense?

Here is my code currently....
The $issue_list variable is the problem where I try to embed the view. When the date doesnt match an issue it returns a blank page for output.

  if (count($pub_date)==1){ //Only one issue date...
    $issue_list_title = 'Also in this issue...';
    $issue_list = views_embed_view('Articles', 'block_1', date('Y-m-d',strtotime($node->field_story_pub_date[0]['value'])), $pub_tid, $node->nid);
     
  }else{ //More than one publication
    $issue_list_title = 'Featured in...';
    foreach($node->field_story_pub_date as $date){
    $issue_list.= str_replace(' - ','',views_embed_view('Articles', 'attachment_3', date('Y-m-d',strtotime($date['value'])), $pub_tid));
    }
  }

 
 

Drupal is a registered trademark of Dries Buytaert.