Copied to clipboard

Flag this post as spam?

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


  • Mus'ab 112 posts 294 karma points notactivated
    1 week ago
    Mus'ab
    0

    Adding a check box property to a doc type require save & publish all nodes to get the value of property !

    Hi

    i have a huge number of nodes with a doc type newsItem

    and when i add a property value check box to it i found that i should save and publish all nodes to handle its value

    how can i solve this problem ?

  • Marc Goodson 1024 posts 6755 karma points MVP 4x c-trib
    1 week ago
    Marc Goodson
    3

    Hi Mus'ab

    The trick here is to name your checkbox in such a way that the 'default' value is served by the checkbox not being present...

    so if you have a checkbox called 'Show Banner', and you want the default behaviour of your pages to be displaying a banner - you hit a problem, as the existing pages do not have the 'Show Banner' checkbox in the published cache, so it can't be found in your template logic to show the banner...

    but if you instead call the checkbox 'Hide Banner' then in your implementation code assume that if the 'Hide banner' checkbox is missing the banner should be shown, as soon as an editor chooses to 'hide a banner' they check the checkbox and publish the page, ensuring the 'Hide Banner' property is available in the published cache, and the razor code can hide the banner...

    It's a workaround strategy, but it does work...

    regards

    marc

  • Mus'ab 112 posts 294 karma points notactivated
    1 week ago
    Mus'ab
    0

    Hi Marc

    Thank you for replay and its a clever solution but in my case the option is that if you want to disable some thing and i have to check if the value is true before i show it so i cant take this solution

  • Marc Goodson 1024 posts 6755 karma points MVP 4x c-trib
    1 week ago
    Marc Goodson
    0

    Hi Mus'ab

    It's the same trick

    Think what is the default behaviour... eg what should happen if nothing is checked???

    You say "I need to check the value is true before I display anything"

    Therefore your checkbox is probably called 'Show Thing'

    and your code checks for a value of Show Thing, and only shows the thing if it is true.

    Now if this thing should only be shown if an editor has explicitly ticked the box, then this is ok, the default behaviour is the Show Thing checkbox it won't exist, so the thing won't be written out as desired...

    When the editor 'ticks' the box and publishes the page the property will be there and the section will be shown if they have ticked the box.

    If the problem is you don't want the editor to have to tick the box on 600 pages, then the question... is the default behaviour that the 'thing should be shown'?

    and would it make sense instead to show it by default and call your checkbox 'Hide Thing'... if that means the editor only has to hide 5 pages...

    regards

    Marc

  • Mus'ab 112 posts 294 karma points notactivated
    5 days ago
    Mus'ab
    0

    yes you are right

    the property should be if a user wants to hide the thing and the only solution that i have is to save and publish more than 600 node

Please Sign in or register to post replies

Write your reply to:

Draft