Dears i want to use the two blocks in a single module this is my code ,<br><br>in 2 block are displayed in the blocks setting place,<br><br><br>i enable both , its not displaying,<br><br>Any idea..<br><br><?php<br>// $Id$<br>
/**<br>* Implementation of hook_block().<br>*<br>* Displays the most recent (x) blog titles on the user profile page. (x) is set in block configuration admin section.<br>*/<br>function ptHeadlines_block($op = 'list', $delta = 0, $edit = array()) {<br>
global $user;<br> switch ($op) {<br> case 'list':<br> $block[0]['info'] = t('More Headline ');<br> $block[0]['title'] = t('More Headline ');<br> <br> $block[1]['info'] = t('Top Headline');<br>
$block[1]['title'] = t('Top Headline');<br> <br> return $block;<br> <br> case 'configure':<br> $form['ptHeadlines_blog_num_posts'] = array(<br> '#type' => 'textfield',<br>
'#title' => t('Number of Headlines to display'),<br> '#default_value' => variable_get('ptHeadlines_blog_num_posts', 5),<br> );<br> return $form;<br> <br> case 'save':<br>
if ($delta == 0) {<br> variable_set('ptHeadlines_blog_num_posts', (int) $edit['ptHeadlines_blog_num_posts']);<br> }<br> return;<br> <br> case 'view':<br> <br> <br>
if (user_access('access content') && $delta == 0 && arg(0)=='user') {<br> $num_posts = variable_get('ptHeadlines_blog_num_posts', 5);<br>// $current_user_profile = arg(1);<br>
$result = db_query_range("select cn.nid,cn.title,nr.title,nr.timestamp,nr.body,nr.teaser from node as cn,node_revisions as nr where cn.nid=nr.nid and cn.type='article'ORDER BY nr.timestamp DESC", NULL, 0,$num_posts);<br>
<br>drupal_set_message("This is the more headline",$result);<br> if (db_num_rows($result)) {<br> $moreHead = array();<br> while ($blog_posts = db_fetch_object($result)) {<br> $moreHead[] = "<p>".l(ucwords($blog_posts->title), 'node/'. $blog_posts->nid)."</p>".substr($blog_posts->teaser, 0, 175)."&nbsp;&nbsp;&nbsp;".l("More","node/".$blog_posts->nid)."<br>";<br>
// $moreHead[]=substr($blog_posts->title, 0, 175)."<br><br><br>";<br><br> }<br> $block['subject'] = t('More Headlines test');<br> // Theme our array of links as an unordered list<br>
$block['content'] = theme('item_list_ameex', $moreHead);<br> // if (db_num_rows($result) == $num_posts) {<br> // //$block['content'] .= '<div class="block-view-more">'. l(t('View more'), 'blog/'. $current_user_profile, array(), NULL, NULL, FALSE, FALSE) .'</div>';<br>
// } <br> }<br> }<br> <br> <br> <br> //this is block for top Headlines<br> <br> if (user_access('access content') && $delta == 0 && arg(0)=='user') {<br>
$num_posts = variable_get('ptHeadlines_blog_num_posts', 5);<br>// $current_user_profile = arg(1);<br> $result = db_query_range("select cn.nid,cn.title,nr.title,nr.timestamp,nr.body,nr.teaser from node as cn,node_revisions as nr where cn.nid=nr.nid and cn.type='article'ORDER BY nr.timestamp DESC", NULL, 0,1);<br>
drupal_set_message("This is the top headline",$result);<br> <br><br> if (db_num_rows($result)) {<br> $topHead = array();<br> while ($blog_posts = db_fetch_object($result)) {<br>
$topHead[] = "<p>".l(ucwords($blog_posts->title), 'node/'. $blog_posts->nid)."</p>".substr($blog_posts->teaser, 0, 175)."&nbsp;&nbsp;&nbsp;".l("More","node/".$blog_posts->nid)."<br>";<br>
// $topHead[]=substr($blog_posts->title, 0, 175)."<br><br><br>";<br><br> }<br> $block['subject'] = t('Top Headlines');<br> // Theme our array of links as an unordered list<br>
$block['content'] = theme('item_list_ameex', $topHead);<br> <br> }<br> }<br> <br> <br> return $block; <br> }<br>}<br><br><br><br>