Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mark Watson 76 posts 216 karma points
    1 week ago
    Mark Watson
    0

    Use Page Id to display content

    Can't get this to work. The following code is in a partial and if the partial displays on the page with id 1089 it should display the content, but it displays nothing with no errors.

    var currentPageId = CurrentPage.Id;
    

    var pageId = 1089; var casesort = Model.Content.Site().FirstChild("caseHistoryPage").Children().Where("pageId != currentPageId") .Where(x => x.HasValue("Catagory") && x.GetPropertyValue

    If I remove .Where("pageId != currentPageId") it displays on all pages that have the partial. I wish it to display only on the page with id 1089.

    Has anyone any ideas where i am going wrong?

  • Søren Gregersen 209 posts 885 karma points c-trib
    1 week ago
    Søren Gregersen
    100

    I don't think you can use expressions like "pageId != currentPageId"

    why not just do (in razor):

    @if(Model.Content.Id == 1089) {
        // show cases...
    }
    
  • Steve Morgan 1020 posts 3179 karma points c-trib
    1 week ago
    Steve Morgan
    1

    Change

    .Where("pageId != currentPageId")
    

    to

    .Where(x => x.Id != currentPageId)
    

    in fact better..

    .Where(x => x.Id != currentPageId  && x.HasValue("Catagory") && ....   etc here)
    
  • Mark Watson 76 posts 216 karma points
    1 week ago
    Mark Watson
    0

    Thanks Soren and Steve

    Both worked for me

Please Sign in or register to post replies

Write your reply to:

Draft