Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Created April 17, 2012 22:07
Show Gist options
  • Save whyisjake/2409387 to your computer and use it in GitHub Desktop.
Save whyisjake/2409387 to your computer and use it in GitHub Desktop.
Test for no results
$results = $json_output -> RES -> R;
if (isset($results)) {
foreach ($results as $item) {
$image = $item->xpath(".//DataObject[@type='cse_image']/Attribute");
if ( !empty($image)) {
echo '<div class="row result"><div class="result">';
echo '<div class="span2">';
if ( function_exists( 'wpcom_vip_get_resized_remote_image_url' ) ) {
echo '<img class="thumbnail" src="' . wpcom_vip_get_resized_remote_image_url( $image[0]->attributes()->$att, '100', '100' ) . '" alt="'.make_linkify($item).'" />';
} else {
echo '<img class="thumbnail" src="';
echo $image[0]->attributes()->$att;
echo '?w=100" width="100" />';
}
echo '</div>';
echo '<div class="span8"><h3><a href="'.make_linkify($item).'">';
make_namify($item);
echo '</a></h3>';
echo '<a href="'.make_linkify($item).'"</a>'.$item->UE.'</a>';
echo '<p>'.strip_tags($item->S).'</p></div></div><div class="clear:both"></div></div><div class="clear:both"></div>';
} else {
echo '<div class="row result"><div class="result">';
echo '<div class="span10"><h3><a href="'.make_linkify($item).'">';
//namify($item);
make_namify($item);
echo '</a></h3>';
echo '<a href="'.make_linkify($item).'"</a>'.$item->UE.'</a>';
echo '<p>'.strip_tags($item->S).'</p></div></div></div> ';
}
}
} else {
echo '<h3>Sorry, no results found...</h3>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment