sdl=com.traction.sdl.tutorial.lesson15
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>SDL Tutorial</title>
<html.css url="/html/css/sdllessons/styles.css" />
</head>
<body>
<h1>SDL 関数</h1>
<#entries-list title="記事 新しい順 5件" type="rchron" />
<#entries-list title="記事 古い順 5件" type="rchron" sort="1" />
<#entries-list title="タスク 締切日の古い順 10件" type="tasks" max="10" sort="10" />
</body>
</html>
<sdl.function name="entries-list">
<h2>${title}</h2>
<entries type="${type}" proj="*" max="<var.value name='max' default='5' />" sort="<var.value name='sort' default='2' />">
<div class="entry">(__loop.index__) __entry.tractionid__ : __entry.title__ (<entry.date dateformat="long" timeformat="long" />)</div>
<loop.none><div class="error">該当する記事が見つかりません。</div></loop.none>
</entries>
<hr>
</sdl.function>
/type lesson15 と入力して Enter キーを押すと、下図のビューが表示されます。title= と type= パラメーターを指定しています。
<#entries-list title="記事 新しい順 5件" type="rchron" />
<#entries-list title="値" /> の title= パラメーターの値は、<sdl.function name="entries-list">...</sdl.function> 内で ${title} や <var.value name="title" /> を使って取得できます。${title}#$title$<var.value name="title" /> <var.get name="title" /> <variable.value name="title" /> <variable.get name="title" /> <variable.local.value name="title" /> <variable.local.get name="title" /> sort= や max= パラメーターの値は、${sort} や <var.value name="max" /> などを使って取得できます。
<sdl.function name="entries-list">
<h2>${title}</h2>
<entries type="${type}" proj="*" max="<var.value name='max' default='5' />" sort="<var.value name='sort' default='2' />">
<div class="entry">(__loop.index__) __entry.tractionid__ : __entry.title__ (<entry.date dateformat="long" timeformat="long" />)</div>
<loop.none><div class="error">該当する記事が見つかりません。</div></loop.none>
</entries>
<hr>
</sdl.function>
<h2>${title}</h2> の ${title} の部分は、title= パラメーターで渡された値に置き換わります。<entries> タグの type= と sort= と max= パラメーターの値は、それぞれ同じ名前のローカル変数(引数)で決まるようになっています。<entries> タグのパラメーター詳細については DocSDK147: SDL Lesson 5 - 記事を投稿順に取得する を参照してください。
<entries type="${type}" proj="*" max="<var.value name='max' default='5' />" sort="<var.value name='sort' default='2' />">
<#entries-list type="tasks" sort="10" /> として呼び出すと、<entries> タグの type= パラメーターの値には「tasks」が渡されます。これにより、<entries> タグは「ジャーナルの中からタスク記事を取得する」という動作を行います。<entries /> タグの sort= パラメーターに値「10」が渡され、「取得したタスク記事を、締切日の古い順に並べる」という動作を行います。<#関数名 パラメーター1="値1" パラメーター2="値2" ... /> のように記述する。lesson15.properties
lesson15.sdl
image1.png