惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

博客园 - jerry data

(转)三维管线自动建模工具PipelineCreator 招聘技巧一二 (转) python抓网页中文乱码问题 - jerry data - 博客园 星 ---- 谷村新司 (转载)arcgis flex api 访问 google 地图 arcgis flex api 访问 google 地图 iframe and margin - jerry data Difference method for Parse XML with C# PInvoke .NET ~ C++ how to call the member function?( C++ ) . or -> "con" function usage tip!! 转载 : flex3 中 Legend fontSize不起作用的bug解决 map service query result maxrecordcount arcmap field calculator Michael F. Goodchild Talks about the Role of Volunteered Geographic Information in a Postmodern GIS World create user with custom profile 唐骏十年管理经验谈:管理者要学会让员工感动 mysql - tutorial 1 theme elements in the form - jerry data
Block development
jerry data · 2009-12-22 · via 博客园 - jerry data

控制block的可用与否,可以在管理员登录网站以后,在Blocks管理页面中,点击指定的block,设置哪些权限用户可以使用该block。 一个module可以创建多个block。

hook_block($op = 'list', $delta = 0, $edit = array())

{

if ($op == 'list') { // drupal 框架会首先使用list参数收集整个程序有哪些block。
$blocks[0]['info'] = t('User login');
// Not worth caching.
$blocks[0]['cache'] = BLOCK_NO_CACHE;

$blocks[1]['info'] = t('Navigation');
// Menu blocks can't be cached because each menu item can have
// a custom access callback. menu.inc manages its own caching.
$blocks[1]['cache'] = BLOCK_NO_CACHE;

$blocks[2]['info'] = t('Who\'s new');

return $blocks;
}

else if ($op == 'view') { // 当需要具体生成block内容的时候,框架使用view参数调用该hook。
$block = array();

switch ($delta) { // 当有多个block时,这个参数指定要渲染按个block,对应的是list里面的数组$blocks索引。
case 0:
// For usability's sake, avoid showing two login forms on one page.
if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {

$block['subject'] = t('User login');
$block['content'] = drupal_get_form('user_login_block');
}
return $block;

case 1:
if ($menu = menu_tree()) {
$block['subject'] = $user->uid ? check_plain($user->name) : t('Navigation');
$block['content'] = $menu;
}
return $block;

case 2:
if (user_access('access content')) {
// Retrieve a list of new users who have subsequently accessed the site successfully.
$result = db_query_range('SELECT uid, name FROM {users} WHERE status != 0 AND access != 0 ORDER BY created DESC', 0, variable_get('user_block_whois_new_count', 5));
while ($account = db_fetch_object($result)) {
$items[] = $account;
}
$output = theme('user_list', $items);

$block['subject'] = t('Who\'s new');
$block['content'] = $output;
}
return $block;
}


要想控制block显示在那个页面路径下可以通过 'pages' => 'node/*',


$blocks[0] = array(
'info' => t('My Profile'),
);
// A block can provide default settings. In this case we'll enable the
// block and make it visible only on the 'node/*' pages.
$blocks[1] = array(
'info' => t('Example: empty block'),
'status' => TRUE,
'weight' => 0,
'visibility' => 1,
'pages' => 'node/*',
);
return $blocks;

block内容通过$block['content']设置,可以直接在代码中写字符串形式的html,也可以调用theme()函数

$block['content'] = '<a>hello ,world </a>';

$block['content'] = theme("item_list",$items);