2

I would like to know if there is a way to modify the output of page fields in SharePoint 2013 from within a snippet or within the page layout.

  • I have a field of type Hyperlink or Picture.
  • I want to simply get only the URL with no formatting.
  • I cannot do this client-side. It is to populate an OG:image meta tag and as such it must be included in the HTML response.
  • I want to do it in the page layout for one particular type of page on my site and not site-wide.

From the snippet editor I see a bunch of template fields, but no idea how to supply the templates.

I did find the control template but that appeared to only be for the edit mode of the control.

I tried adding my hyperlink or picture column directly to the page layout using the code below:

<!--MS:<PageFieldFieldValue:FieldValue FieldName="Thumbnail" runat="server">-->

This produces the following output:

<a href="http://[my site url]/public/news/PublishingImages/bills-1.jpg">The Energy Information Administration is forecasting a slight rise in electricity prices in 2017.</a>

What I would like to get as output is:

http://[my site url]/public/news/PublishingImages/bills-1.jpg

How do I affect the READ mode of the output or specify only the URL portion of my Thumbnail column?

Alternatively, can I somehow format the data within the page layout if I don't have code-behind?

I'm stumped as to how to do this.

Your Answer

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

Browse other questions tagged or ask your own question.