[support] how to use the 2 blocks in single module
bharani kumar
bharanikumariyerphp at gmail.com
Tue Jun 24 18:27:22 UTC 2008
but u see this is my entire,
Already there i used the switch case,for the configure purpose ,view and so,
Then how can i use , for the $deleta...
<?php
// $Id$
/**
* Implementation of hook_block().
*
* Displays the most recent (x) blog titles on the user profile page. (x) is
set in block configuration admin section.
*/
function ptHeadlines_block($op = 'list', $delta = 0, $edit = array()) {
global $user;
switch ($op) {
case 'list':
$block[0]['info'] = t('More Headline');
$block[0]['title'] = t('More Headline');
return $block;
case 'configure':
$form['ptHeadlines_blog_num_posts'] = array(
'#type' => 'textfield',
'#title' => t('Number of Headlines to display'),
'#default_value' => variable_get('ptHeadlines_blog_num_posts', 5),
);
return $form;
case 'save':
if ($delta == 0) {
variable_set('ptHeadlines_blog_num_posts', (int)
$edit['ptHeadlines_blog_num_posts']);
}
return;
case 'view':
if (user_access('access content') && $delta == 0 && arg(0)=='user') {
$num_posts = variable_get('ptHeadlines_blog_num_posts', 5);
// $current_user_profile = arg(1);
$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, 1, $num_posts);
if (db_num_rows($result)) {
$items = array();
while ($blog_posts = db_fetch_object($result)) {
$items[] = "<p>".l(ucwords($blog_posts->title), 'node/'.
$blog_posts->nid)."</p>".substr($blog_posts->teaser, 0,
175)." ".l("More","node/".$blog_posts->nid)."<br>";
// $items[]=substr($blog_posts->title, 0, 175)."<br><br><br>";
}
$block['subject'] = t('More Headlines');
// Theme our array of links as an unordered list
$block['content'] = theme('item_list_ameex', $items);
// if (db_num_rows($result) == $num_posts) {
// //$block['content'] .= '<div class="block-view-more">'.
l(t('View more'), 'blog/'. $current_user_profile, array(), NULL, NULL,
FALSE, FALSE) .'</div>';
// }
}
}
//this is block for top Headlines
return $block;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20080624/48e0acdd/attachment.htm
More information about the support
mailing list