使用SharePoint Designer 2013按頁眉/標題查詢列表視圖Webpart


2

正在努力將頁面標題作為變量放入列表視圖Web部件查詢中,代碼如下,請注意,我希望標題位於主要內容區域上方,而不是下面的實際HTML標題(不同)。

如果我手動鍵入頁面標題,則查詢工作正常,因此數據僅需插入一些將頁面標題拉至字符串的代碼即可

             <Query>
                <Where>
                    <Eq>
                        <FieldRef Name="Client_x0020_Code"/>
                        <Value Type="Text">THIS TEXT NEEDS TO BE A VAR</Value>
                    </Eq>
                </Where>
            </Query>

enter image description here

嘗試粘貼

     <SharePoint:ListProperty Property="CurrentViewTitle" runat="server"/>

但是它會中斷頁面。

0

After a long struggle with the SPD, finally I got the solution for you. The solution is made for Site Pages. Follow the steps:

  1. Open the Site Page in SPD.
  2. Search for ParameterBinding tag and at the bottom add another tag having this code: <ParameterBinding Name="TestTitle" Location="Control(wikiPageNameEditTextBox)" />
  3. Now open the XSLT List View WP and add Caml Query to it. I am using single query where checking for Title equals page title. My query looks like this:

<Where> <Eq> <FieldRef Name="Title"/> <Value Type="Text">{TestTitle}</Value> </Eq> </Where>

  1. Save the page in designer and run the page on browser.

If you change the title of the page to the matching item title, it will display the item.

In addition to this, I also figured out if the text box having ID is not available on page, then you can create a custom text box within span having ID wikiPageNameEdit and add JS below it to add page title.

So the final code look like this in SPD:

enter image description here

And the output of code is following: https://i.imgur.com/rpJ7ACo.mp4

I hope this helps.