[Last Updated Promotions (最後に更新されたプロモーション)] ボックスを [Visualforce Article Search (Visualforce 記事検索ページ)] に追加する
最後に、[Last Updated Promotions (最後に更新されたプロモーション)] ボックスを追加します。
- [Visualforce Article Search (Visualforce 記事検索)] タブの下部にあるフッターで、[ArticleList] をクリックして Visualforce 開発モードのページエディタを表示します。
- Visualforce 開発モードのページエディタで既存のマークアップをすべて削除し、「Visualforce ボックスのコードサンプル」に表示されているマークアップに置き換えます。
-
[保存] (
) をクリックします。
Visualforce ボックスのコードサンプル
太字の行については、コードサンプルの後に説明があります。
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<apex:page controller="VfSearchController" sidebar="false" title="Knowledge Search">
18<style>
19 td{
20 vertical-align : top;
21 text-align: left;
22 }
23</style>
24<apex:form >
25 <apex:panelGrid columns="2" >
26 <apex:panelGroup >
27 <apex:pageBlock >
28 <apex:outputText value="Filter Your Results" />
29 <apex:pageBlockSection columns="1">
30 <apex:dataTable value="{!dataCategoryGroupInfo}" var="dataCategory" id="dataCategory">
31 <apex:column width="20%">
32 <apex:outputLabel for="categoryType_{!dataCategory.name}">{!dataCategory.name}</apex:outputLabel>
33 <br />
34 <select id="categoryType_{!dataCategory.name}" name="categoryType_{!dataCategory.name}" onchange = "refreshSearchResult()" >
35 <option value="NoFilter">No Filter</option>
36 <option value="All">All</option>
37 <knowledge:categoryList categoryVar="category" categoryGroup="{!dataCategory.name}" rootCategory="All" level="-1">
38 <option value="{!category.name}">
39 <apex:outputText escape="false" value="{!LPAD(' ',6*category.depth,' ')}" />
40 {!category.label}
41 </option>
42 </knowledge:categoryList>
43 </select>
44 </apex:column>
45 </apex:dataTable>
46 </apex:pageBlockSection>
47 </apex:pageBlock>
48 <apex:pageBlock >
49 <apex:outputText value="Last Updated Promotions" />
50 <apex:pageBlockSection columns="1">
51 <knowledge:articleList articleVar="article" articleTypes="Promotion__kav" pageSize="10" >
52 <li>
53 <apex:outputLink target="_blank" value="{!URLFOR($Action.KnowledgeArticle.View, article.id, ['popup' = 'true'])}">{!article.title}</apex:outputLink>
54 </li>
55 </knowledge:articleList>
56 </apex:pageBlockSection>
57 </apex:pageBlock>
58 </apex:panelGroup>
59 <apex:panelGroup >
60 <apex:pageBlock title="Search" >
61 <apex:inputText value="{!searchstring}" id="theSearchstring" maxlength="100" size="110" onkeypress="if (event.keyCode == 13) {refreshSearchResult();return false;} "/>
62 <apex:commandButton value="Go" id="submitButton" style="width:30" reRender="theSearchResults" />
63 </apex:pageBlock>
64 <apex:messages />
65 <apex:panelGroup id="theSearchResults" >
66 <apex:pageBlock title="Search Results" >
67 <apex:panelGrid width="100%">
68 <table width="99%">
69 <tr>
70 <th width="33%">Title</th>
71 <th width="33%">Article Type</th>
72 <th width="33%">Summary</th>
73 </tr>
74 </table>
75 <knowledge:articleList articleVar="article" categories="{!categoryKeyword}" Keyword="{!searchstring}" pageNumber="{!currentPageNumber}" hasMoreVar="false" pageSize="10">
76 <table width="99%">
77 <tr>
78 <td width="33%">
79 <apex:outputLink target="_blank" value="{!URLFOR($Action.KnowledgeArticle.View, article.id,['popup' = 'true'])}">{!article.title}</apex:outputLink>
80 </td>
81 <td width="33%"><apex:outputText >{!article.articleTypeLabel}</apex:outputText></td>
82 <td width="33%"><apex:outputText >{!article.abstract}</apex:outputText></td>
83 </tr>
84 </table>
85 </knowledge:articleList>
86 </apex:panelGrid>
87 </apex:pageBlock>
88 <apex:panelGrid columns="2">
89 <apex:commandLink action="{!previous}" value="Previous" style="{!IF(prevRequired = true,'display:block','display:none')}" reRender="theSearchResults"/>
90 <apex:commandLink action="{!next}" value="Next" style="{!IF(nextRequired = true,'display:block','display:none')}" reRender="theSearchResults"/>
91 </apex:panelGrid>
92 </apex:panelGroup>
93 </apex:panelGroup>
94 </apex:panelGrid>
95 <apex:actionFunction action="{!refreshSearchResult}" name="refreshSearchResult" rerender="theSearchResults" >
96 </apex:actionFunction>
97
98
99 </apex:form>
100</apex:page>次のコードフラグメントでは、<knowledge:articleList> タグで、最後に公開された記事をデフォルトで取得します。articleTypes 属性では、プロモーション記事のみを [Last Updated Promotions (最後に更新されたプロモーション)] ボックスに表示するように指定します。
1<apex:outputText value="Last Updated Promotions" />
2<apex:pageBlockSection columns="1">
3 <knowledge:articleList articleVar="article" articleTypes="Promotion__kav" pageSize="10" >
4 <li>
5 <apex:outputLink target="_blank" value="{!URLFOR($Action.KnowledgeArticle.View, article.id, ['popup' = 'true'])}">{!article.title}</apex:outputLink>
6 </li>
7</knowledge:articleList>これまでの作業を確認する
[Visualforce Article Search (Visualforce 記事検索)] ページの左ペインに [Last Updated Promotions (最後に更新されたプロモーション)] ボックスが表示されています。このボックスには、新しいプロモーションまたは最近更新されたプロモーションが表示されます。