您在這裡

Content Templates (Contemplate)

charlesc's 的頭像
charlesc 在 2006-09-21 (四) 00:30 發表
模組介紹: 

可以很容易地調整每個內容類型的摘要(teaser)和全文的顯示欄位,它會把可使用的物件列出來,只要在上面按一下,就會把對應的程式碼加到版型裡,並可手動作細部調整。適合與 CCK 合用。

模組分類:

模組版本:

回應

[應用實例]
如何在同一頁面顯示 線上報名 和 報名一覽表 的這二個區塊
http://140.127.53.222/lib/courses/node/18277

重點在於
1.顯示 線上報名
print $node->signup_view

2.顯示 報名一覽表
print views_build_view('embed', $view, $view_args, false, false); //Templates的方法
但是要找出$view與$view_args[]
所以下面這兩行要放views_build_view方法的前面
$view = views_get_view('signup_user_list'); //插入views
$view_args[] = $node->nid;

完整程式碼:

課程資訊

課程名稱

<?php print $node->title ?>

上課時間

上課開始:<?php print $node->event['start'] ?>
上課結束:<?php print $node->event['end'] ?>

上課地點

<?php print $node->field__104[0]['view'] ?>

上課內容

<?php print $node->field__105[0]['view'] ?>

主講人

<?php print $node->field__107[0]['view'] ?>

簡介與講義

<?php foreach ((array)$node->field__106 as $item) { ?>
<?php print $item['view'] ?>

<?php } ?>

已報名/人數限制

正取: <?php print $node->signup_status_cid_totals[1] ?> / <?php print $node->signup_status_close_cid_limits[1] ?>
備取: <?php print $node->signup_status_cid_totals[2] ?> / <?php print $node->signup_status_close_cid_limits[2] ?>

報名期限

報名開始:<?php print format_date($node->signup_scheduler_open) ?>
報名結束:<?php print format_date($node->signup_scheduler_close) ?>

注意事項
(1) 請線上報名,如該次課程報名人數不足 5人,即取消該次課程。
(2) 點選課程名稱,即可查閱課程詳細資訊。
(3) 已報名者請務必準時出席,以免影響他人參加權益。
(4) 若有事無法參加,請於兩日前上網自行取消報名,否則取消本年度上課資格。
(5) 10人以上可自行組隊參加講習,請洽參考館員(分機 1430 )另約講習時間。
(6) 如對課程有疑問,請電詢推廣服務組(分機 1430 )。

 

線上報名

<?php print $node->signup_view ?>

 

報名狀況一覽表

<?php
//http://drupal.org/node/134320
// load view
// using the views_get_view() function we can "load" a view into a local variable: $view
$view = views_get_view('signup_user_list');

// once loaded we can adjust some of the parameters of the view
// one of the views arguments, if you remember, is "Node Reference: Type A (parent_type_a)"
// we can pass a specific value to the view, for this we want to pass the value of the "type_a" node's nid ($node->nid)

// argument values are passed via a PHP array so we need
$view_args[] = $node->nid;

// we are now ready to "build" and print out the view
// for this we use the views_build_view() function
// the last 2 values: "TRUE" and "20" allow us to have the list paged at 20 rows
print views_build_view('embed', $view, $view_args, false, false);
?>

 

感謝nobody1225 測試後 因我的環境是 drupal 6.0 改了一下程式碼

重要的地方在於
1.顯示 線上報名
<?php print $node->content['signup']['#value'] ?>

2.顯示 報名一覽表
<?php print $node->content['signup_list']['#value'] ?>

3. 完整 程式碼 如下:

活動資訊

活動名稱

<?php print check_plain($node->title) ?>

活動時間

<?php print $node->field_course_time[0]['view'] ?>

活動地點

<?php print $node->field_course_place[0]['view'] ?>

活動內容

<?php print $node->field_syllabus[0]['view'] ?>

主講人

<?php print $node->field_course_host[0]['view'] ?>

簡介與講義

<?php foreach ((array)$node->field_course_lecture as $item) { ?>

<?php print $item['view'] ?>

<?php } ?>

報名期限

<?php print $node->field_time_limit[0]['view'] ?>

已報名/人數限制

<?php print $node->signup_total ?> / <?php print $node->signup_close_signup_limit ?>

備註
<?php print $node->field_remark[0]['view'] ?>

線上報名

<?php print $node->content['signup']['#value'] ?>

報名狀況一覽表

<?php print $node->content['signup_list']['#value'] ?>