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 82 posts 253 karma points
    Mar 14, 2019 @ 06:41
    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 265 posts 1078 karma points c-trib
    Mar 14, 2019 @ 07:04
    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 1022 posts 3184 karma points c-trib
    Mar 14, 2019 @ 09:04
    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 82 posts 253 karma points
    Mar 14, 2019 @ 22:42
    Mark Watson
    0

    Thanks Soren and Steve

    Both worked for me

Please Sign in or register to post replies

Write your reply to:

Draft