Can't display block in panel
I'm new to drupal, and very new to panels. I have a custom module which displays rss feed items based on user taxonomy. It displays the correct info as a block, but it needs to be on the users' dashboard page, which uses panels. When I try to insert it, it is always blank.
The code inserts a default view I already created, showing all feed items (1_feeds_defaults_feed_items) into a block. I can't edit it to work in a panel. I imagine that there are 10 different things I may have done wrong, but have tried every permutation I can think of.
<?php
//.this function generates a block and calls the second
//function for the content of this block
function custom_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$block[0]['info'] = 'Custom View';
$block[2]['cache'] = BLOCK_NO_CACHE;
return $block;
break;
case 'view':
switch ($delta) {
case 0:
$block['subject'] = '';
$block['content'] = custom_userfeeds() ;
break;
}
return $block;
}
}
function custom_userfeeds() {
//finds the user id from a开发者_运维问答rgument on user page.
//You can also find the user id the way the page you linked me to did,
//but if you do it the way I am below it would allow admins
//to view other users feeds
$uid = arg(1);
//loads the profile node -- 'profile' is the profile content type.
$node = content_profile_load('profile', $uid);
//find the terms associated with the user's profile
if ($node && $node->taxonomy) {
foreach($node->taxonomy as $term) {
$terms[] = $term->tid;
}
}
//embeds a view with those terms passed to it.
View display is something like block_1 or page_1
if($terms) {
$t = implode('+',$terms);
return views_embed_view("1_feeds_defaults_feed_items","page_1", $t);
}
}
Here is how I fixed it in a view: -Add Argument -> Taxonomy -> Taxonomy Term ID -Provide default argument -PHP Code -PHP argument code:
global $user;
$query = "SELECT tid FROM {term_user} WHERE uid = %d";
$result = db_query($query, $user->uid);
if ($result) {
$terms = array();
while ($term = db_fetch_array($result)) {
$terms[] = $term['tid'];
}
if ($terms) {
$termargs = implode("+", $terms);
return $termargs;
}
}
else {
return FALSE;
}
-Check "Allow multiple terms per argument."
精彩评论