「データベーステンプレート」の版間の差分

提供:MoodleDocs
移動先:案内検索
14行目: 14行目:
* ##Delete## 現在のエントリを削除するためリンクを作成します (あなたに権限がある場合のみ表示されます)。
* ##Delete## 現在のエントリを削除するためリンクを作成します (あなたに権限がある場合のみ表示されます)。
* ##Approve## 現在のエントリを認証するためのリンクを作成します (あなたに権限がある場合のみ表示されます)。
* ##Approve## 現在のエントリを認証するためのリンクを作成します (あなたに権限がある場合のみ表示されます)。
* ##Comments## creates a link to the view/edit comments page, the link text is the current number of comments (only appears if comments are turned on)
* ##Comments## コメントページの表示/編集リンクを作成します。リンクテキストは現在のコメント数です (コメントが有効にされている場合のみ表示されます)
* ##User## creates a link to the user page of the user who submitted the entry, link text is their name
* ##User## creates a link to the user page of the user who submitted the entry, link text is their name



2007年11月27日 (火) 04:30時点における版


作成中です - Mitsuhiro Yoshida 2007年11月23日 (金) 19:58 (CST)

データベースモジュールのテンプレートでは、データベースエントリを一覧表示、閲覧、編集する場合のビジュアルレイアウトをコントロールします。これは、Open Office WriterまたはMicrosoft Wordのようなワードプロセッサの「メールマージ」機能で使用される技術に類似しています。

タグの使用

あなたがデータベースに作成したコンテンツのフィールドおよびスペシャルタグ (以下に記載) は、タグを使用した出力テンプレートに挿入することができます。左サイドにあるタグを使用するには、HTMLエディタであなたが編集したい場所をクリックしてください。左サイドのボックス内にある使用したいタグをクリックするとエディタ内にタグが配置されます。または、次のように必須記号に挟まれたタグ名を入力することでタグを配置できます ##this## または [[this]]。

  • ##Edit## 現在のエントリを編集するためのリンクを作成します (あなたに権限がある場合のみ表示されます)。
  • ##More## さらに詳細情報を含んでいるデータの個別表示のためのリンクを作成します。
  • ##MoreURL## データベースエントリの直リンクのURLを作成します。「More」および「URL」の間に空白は入りませんので注意してください。テキストを入力および選択した後、HTMLエディタのリンクアイコンをクリックして「##MoreURL##」と入力することができます。また、HTMLエディタをHTMLソースモードにして次のように入力することもできます: <a href="##moreurl##">[[fieldname]]</a>
  • ##Delete## 現在のエントリを削除するためリンクを作成します (あなたに権限がある場合のみ表示されます)。
  • ##Approve## 現在のエントリを認証するためのリンクを作成します (あなたに権限がある場合のみ表示されます)。
  • ##Comments## コメントページの表示/編集リンクを作成します。リンクテキストは現在のコメント数です (コメントが有効にされている場合のみ表示されます)。
  • ##User## creates a link to the user page of the user who submitted the entry, link text is their name

Here's a video demonstrating tag usage: http://video.google.com/videoplay?docid=7026851446099005477

一覧表示テンプレート

This template allows you to control the fields used and their layout when viewing multiple entries at once (e.g. search results). It is possible that this view may simply provide an overview with more detailed information available by clicking on an entry to access the single view of the entry.

The list template can also be used as a way to export your database as a CSV file

個別表示テンプレート

This is used to display a single entry at a time and so has more space for display and can use, for example, larger versions of images or optionally provide more information than shown in the list view.

テンプレートの追加

This template creates the interface form used when adding or editing database entries. Saving a template will overwrite whatever template you have already saved. The ability to create (and import and export) named templates for re-use is planned but not yet functional. Currently you can copy and paste your template for reuse elsewhere.

RSSテンプレート

Lets you control the content of the RSS feed for database entries.

CSSテンプレート

If any of the HTML in your other templates requires CSS to provide visual style you can specify it here.

Javaスクリプトテンプレート

You can use javascript to manipulate the way elements are displayed in either the List, Single or Add templates. Basically you need to enclose the part you want to manipulate in some named html element. The naming is essential as it allows you to identify the element for manipulation.

Lets say, for example, you have a field in your database that stores a persons name and when you display the names in the List View you want to count the times a name matches some criteria and display the result.

Your database will contain a field which we will call "name". In your List template you will be able to display the contents of that field by using the [[name]] construct at the place where you want that information displayed. For example in the Repeated entry on the list template you will have

 <table>
   <tr>
     <td>Name: [[name]]</td>
   </tr>
 <table>  

You now need to modify that entry to ensure that the part you want to manipulate is a named element.

 <table>
   <tr>
     <td name="named">Name: [[name]]</td>
   </tr>
 <table>  

The footer of your list view can then contain another named element to display the result.

  <div name="result"></div>

Your javascript template can now look as follows

 var cnt = 0;
 var re = /foo|Foo/;
 
 function init(){
   var namedElements = document.getElementsByName("named");
   for (i=0; i < namedElements.length; i++) {
       if(re.test(namedElements[i].innerHTML)) cnt++;
     }
   var namedResult = document.getElementsByName("result");
   namedResult[0].innerHTML = cnt;
   }
 
 window.onload = init;

This will display a table of names as is usual in the list view. Now at the bottom there will also be the count of the names that matched foo or Foo.

テンプレートのリセットボタン

When you first create a database the templates will be pre-filled with appropriate HTML. If you later add fields then you can press the reset templates button and it will add HTML for the new fields in a similar fashion. If you have edited any of the templates in the meantime then your changes will be lost. It is recommended that you finalize the database fields before changing the template code.

関連情報

Some Using Moodle forum discussions: