Struggling to get the page header as a variable into a List view Web Part query, code below, note that i want the header above the main content area, not the actual HTML title (it is different) pic below.

The Query works fine if i type the page header in manually, so the data is there just need to insert some code that pulls the page header to string:

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

enter image description here

Have tried like pasting in

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

But it breaks the page.

  • I am not getting what you are trying to do? Are you working on Site Page code directly using SPD? Or you are using some object model? – ThinkB4Code Sep 13 '17 at 10:47
  • Yep working on a page directly in SPD (it will be a template), it has a list view a the top and i want to filter it by the page header text – Simon M Sep 13 '17 at 10:58
  • Just for clarification, why you want to filter based on Page title? Cant you create a page, place the LVWP, pass the filter as query string, use List view filter WP using query string and finally place a JS at the bottom which will replace Page tile using query string? – ThinkB4Code Sep 13 '17 at 11:06
  • is there any hard rule that you have to go by Page title only? – ThinkB4Code Sep 13 '17 at 11:06
  • The structure of the site is a main list, and then doc libraries with a LVWP back to that main list, i want the list to be filtered by the doc library's name. This is so we can save the finished doc library as a template and just create new ones that will bring in records from the list relating to that doc library. – Simon M Sep 13 '17 at 11:15

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.

| improve this answer | |
  • Thanks for the tip, its not quite working but i think this is nearly the solution i need - it doesnt match because the page title is actually "XXXX - All documents" (its a library), is there a call we can make that returns the page header rather than the html title? ie Client-Template instead of Client-Template - All Documents, or is there are way of renaming the library to remove the "all documents" part of the name? thanks again :) – Simon M Sep 13 '17 at 13:35
  • In that case JS will come handy. Create a new Text Box <asp:TextBox id="myTitle" CssClass="myTitle" runat="server"></asp:TextBox>. Below this text box, add following script. <script> var obj = document.getElementsByClassName('myTitle')[0]; obj.value = document.getElementById('DeltaPlaceHolderPageTitleInTitleArea').innerText.split('-').trim();. This will solve your case. – ThinkB4Code Sep 13 '17 at 13:43
  • Just Test the JS first on browser, if its throwing any error or not. As I had not test it. – ThinkB4Code Sep 13 '17 at 13:43
  • And if that solves your query you can upvote and mark it as answer. :) – ThinkB4Code Sep 13 '17 at 13:44
  • It didnt actually work on my current solution, i couldnt get it to make the page title correct, but this solution did work on some blank wiki pages i tested so thanks for the tips they do work. i think i'm going to try and get this to work by using subsite templates and REST to push data back to a master list - thanks for your help. +1 – Simon M Sep 14 '17 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.