我正在尝试将以下两个Drupal7函数结合起来,但它破坏了站点。任何想法?我正在使用“视图”和“ Profile2”字段中的两个条件。
function mytheme_views_pre_render(&$view) {
if ($view->name == ‘view_name’ && $view->current_display == 'page_1') {
$profile = profile2_load_by_user($user, 'main');
$field_name_val=$profile->field_custom[‘und'][0]['value']
if ($field_name_val == ‘0’) {
if (empty($view->result)) {
$attachment = views_embed_view(‘view_name’’, ‘page_2’);
$view->attachment_after = $attachment;
}
}
if ($field_name_val == ‘1’) {
if (empty($view->result)) {
$attachment = views_embed_view(‘view_name’’, ‘page_3);
$view->attachment_after = $attachment;
}
}
}
}