1

We want to add a Modified By and Modified 'footer' on our wiki pages. We can do this by adding the following code in SharePoint Designer:

    Modified By: 
<SharePoint:UserField FieldName="Modified By" runat="server" ControlMode="Display"/>
on: 
<SharePoint:DateTimeField FieldName="Modified" runat="server" ControlMode="Display"/>

This works fine, but we get the message below on our page. enter image description here

We can fix this with a script editor webpart and add the following code:

<style>
#DeltaPageStatusBar { display: none; }

The problem now is that we can't edit the page anymore. enter image description here

We found this article: https://www.linkedin.com/pulse/unable-edit-pages-sharepoint-2013-how-wiki-balaji-godase/ . We can use this in our URL '?WikiPageMode=Edit&WikiMergeTarget=true', it does work. But our users can't edit the wiki pages anymore without adding this line to the URL.

Does anyone know how this can be solved in another way?

2
  • Does the alert message show to all users? I am just wondering if you are trying to fix an issue that is only affecting you or a small subset of users. It depends on what permissions are used in your site; that dictates the scope of people affected. You can use CSS to hide the alert as well. Commented Sep 12, 2018 at 21:45
  • The alert is visible to all users. But the main problem is that we can't edit the wiki page anymore when we add the 'footer' with SharePoint Designer. We can't ask our users to put '?WikiPageMode=Edit&WikiMergeTarget=true' at the end of the URL when they want to edit the page.
    – NuggetzNL
    Commented Sep 13, 2018 at 8:59

2 Answers 2

1

You may inject these information by Rest api and jQuery, sample script:

<div id="modifiedDate"></div>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        function getModifiedDate() {
            var listId = _spPageContextInfo.pageListId.replace('{', '').replace('}', '');
            var itemId = _spPageContextInfo.pageItemId;
            $.ajax({
                url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists(guid'" + listId + "')/items?$select=Modified&$filter=ID eq " + itemId,
                method: "GET",
                headers: {                    
                    "Accept": "application/json;odata=verbose",
                    "X-RequestDigest": $("#__REQUESTDIGEST").val(),                    
                },
                success: function (data) {                    
                    $("#modifiedDate").html("Page Modified on: " + data.d.results[0].Modified);
                },
                error: function (data) {
                    console.log(data);
                }
            });
        }

        $(document).ready(function () {
            getModifiedDate();
        });
    </script>

Update:

<div id="modifiedDate"></div>
    <div id="ModifiedBy"></div>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        function getModifiedDate() {
            var listId = _spPageContextInfo.pageListId.replace('{', '').replace('}', '');
            var itemId = _spPageContextInfo.pageItemId;
            $.ajax({
                url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists(guid'" + listId + "')/items?$select=Modified,Editor/FirstName&$expand=Editor&$filter=ID eq " + itemId,
                method: "GET",
                headers: {                    
                    "Accept": "application/json;odata=verbose",
                    "X-RequestDigest": $("#__REQUESTDIGEST").val(),                    
                },
                success: function (data) {                    
                    $("#modifiedDate").html("Page Modified on: " + data.d.results[0].Modified);
                    $("#ModifiedBy").html("Page Modified by: " + data.d.results[0].Editor.FirstName);
                },
                error: function (data) {
                    console.log(data);
                }
            });
        }

        $(document).ready(function () {
            getModifiedDate();
        });
    </script>
5
  • I never worked with Rest api and jQuery, how can I inject this? With SharePoint Designer?
    – NuggetzNL
    Commented Sep 13, 2018 at 8:50
  • Just insert script editor webpart/content editor webpart into wiki page and insert the script into webpart.
    – Lee
    Commented Sep 13, 2018 at 9:36
  • Thank you, this works fine for the modified date! Is there also a script for the 'Modified By' option?
    – NuggetzNL
    Commented Sep 13, 2018 at 11:59
  • Check my update
    – Lee
    Commented Sep 14, 2018 at 1:28
  • Thank you very much, this is exactly what we need! We don't need to edit the pages with SharePoint Designer anymore.
    – NuggetzNL
    Commented Sep 14, 2018 at 6:10
0

To hide that status bar message there are multiple ways available on below question,

"The current page has been customized from its template. Revert to template."

Best one i like is that use javascript to hide that, as it will give you some flexibility to show other messsages on status bar.

If status Bar hiding give some issue then try below method,

  • Open site in designer
  • Select target page and from the ribbon click on export and save somewhere.
  • In the designer make backup copy of that page and delete the page
  • Import the exported page
  • Done.

After opening the page in browser if you see below error

Type 'Microsoft.SharePoint.WebControls.EmbeddedFormField' doesn't have public property called 'div'

then just surround the whole content of PlaceHolderMain inside div, save the page and done.

3
  • I can hide the status message bar with script editor. But the problem is that we can't edit the wiki page anymore after editing the page in SharePoint Designer. A user also can't edit the wiki page anymore, only when the put '?WikiPageMode=Edit&WikiMergeTarget=true' behind the URL.
    – NuggetzNL
    Commented Sep 13, 2018 at 8:48
  • I have edited my answer kindly check that
    – Atharullah
    Commented Sep 13, 2018 at 9:53
  • Thank you, this works for the status bar. But the problem with editing the wiki page still persists. This is because I have added some lines in SharePoint Designer. Maybe we can solve this by using the solution of Lee_MSFT, we only need a script for Modified By.
    – NuggetzNL
    Commented Sep 13, 2018 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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