Quantcast
Viewing all articles
Browse latest Browse all 26374

Customize blog post display

Hello, I was tasked with modifying the field that our blog posts shows as the "by" in the metadata at the top of each blog post. In other words, by default they display as "by Author at Time in Category". We have a custom field called"Post Owner" that we want to display instead of the author, as often the author will be one of our admins and not the person in charge of the content.

On our main news feed page, which is a list view, I was able to modify it using the JSLink property of the list view web part, and linking to this script:

(function () {
    var overrideCtx = {};
    overrideCtx.Templates = {};
    overrideCtx.Templates.Fields = {
        'Author': { 'View': GetPostOwner}
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function GetPostOwner(ctx) {
    var ret;
    if (ctx.CurrentItem.Post_x0020_Owner[0] != undefined)
        ret = '<strong>' + ctx.CurrentItem.Post_x0020_Owner[0].title + '</strong>';
    else
        ret = '<strong>' + ctx.CurrentItem.Author[0].title + '</strong>';
    return ret;
}

Of course, this is just for the List View of the blog posts. If you click on a blog post and view it directly this no longer applies. How can I modify the individual blog posts, or how they are displayed? Can't figure it out O_o

Thanks in advance. Scott.


Viewing all articles
Browse latest Browse all 26374

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>