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 118 posts 384 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 441 posts 1884 karma points MVP 2x 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 1350 posts 4460 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 118 posts 384 karma points
    Mar 14, 2019 @ 22:42
    Mark Watson
    0

    Thanks Soren and Steve

    Both worked for me

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies