Copied to clipboard

Flag this post as spam?

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


  • Daniel 20 posts 40 karma points
    Feb 27, 2012 @ 17:11
    Daniel
    0

    items displaying regardless of option picked

    I've created a function to toggle on/off ('visPrisliste') content pulled from a parent node ('Sprog'), but the content is shown regardless if there's a selection in the true/false selection type I've made for it.

    I've probably made a mistake in the Razor script, so if you can spot the error, please point it out to me.

    @{ var langNode = Model.AncestorOrSelf("Sprog"); }  

    @if(@Model.visPrisliste == true) {
      <div class="priceWrap">
        <div class="goldColumn">
          <h5>@Dictionary["guld"]</h5>
          <ul>
            <li><strong>8 @Dictionary["karat"]</strong> @{@langNode.gEight} <span>@{@langNode.gValuta}</span></li>
            <li><strong>14 @Dictionary["karat"]</strong> @{@langNode.gFourteen} <span>@{@langNode.gValuta}</span></li>
            <li><strong>18 @Dictionary["karat"]</strong> @{@langNode.gEighteen} <span>@{@langNode.gValuta}</span></li>
            <li><strong>22 @Dictionary["karat"]</strong> @{@langNode.gTwentytwo} <span>@{@langNode.gValuta}</span></li>
            <li class="last"><strong>24 @Dictionary["karat"]</strong> @{@langNode.gTwentyfour} <span>@{@langNode.gValuta}</span></li>
          </ul>
        </div>
      
        <div class="sivlerColumn">
          <h5>@Dictionary["silver"]</h5>
          <ul>
            <li><strong>@Dictionary["Finsølv"]</strong> @{@langNode.sFine} <span>@{@langNode.sValuta}</span></li>
            <li><strong>@Dictionary["Sterlingsølv"]</strong> @{@langNode.sSterling} <span>@{@langNode.sValuta}</span></li>
            <li class="last"><strong>@Dictionary["Tretårnet"]</strong> @{@langNode.sTree} <span>@{@langNode.sValuta}</span></li>
          </ul>
        </div>
      
      
      </div><!-- /priceWrap -->
    }
  • Rodion Novoselov 694 posts 859 karma points
    Feb 27, 2012 @ 17:36
    Rodion Novoselov
    0

    Hi. What's the datatype of the "visPriselist" property? You could try to add something like:

    @Model.visPriselist.GetType()

    to the top of your macro to validate that it really returns a boolean value as it's expected.

    I suspect that for some reason it returns in fact a string like "true/false".

  • Daniel 20 posts 40 karma points
    Feb 27, 2012 @ 18:22
    Daniel
    0

    The 'visPrisliste" property is in fact a True/False datatype. I'm kind of new to Razor, so what influence does this have? Should I pick something else as a datatype?

  • Rodion Novoselov 694 posts 859 karma points
    Feb 27, 2012 @ 20:34
    Rodion Novoselov
    0

    It should return a bool in such a case. Though I'm not sure for all versions of umbraco. What version do you use?

  • Rodion Novoselov 694 posts 859 karma points
    Feb 27, 2012 @ 20:48
    Rodion Novoselov
    0

    The code itself looks perfect - the only thing that can be wrong is the value that the property returns. I would try just to return its value itself - for instance simply to insert a string of code like

    <div>
       @Model.visPrisliste
    </div>

    somewhere outside that "@if" and inspect what value it outputs than.

  • Daniel 20 posts 40 karma points
    Feb 27, 2012 @ 22:04
    Daniel
    0

    I've tried what you suggest, and nothing appears to show up after saving and reloading the page.

    I'm starting to think this is tied to another issue with the site, one where each change to the site has to be refreshed through a recycle of the app pool on the server. However, usually after such a recycle the changes normally show up, whereas now they don't - at least certain cshtml document changes doesn't. The site is acting very peculiar.

    I've tried to republish everything and refresh the app pool without no effect. It appears that the cshtml file is saved (by verifying through ftp) but no effect is apperant at the website. I posted about it here: http://our.umbraco.org/forum/getting-started/installing-umbraco/29189-Recycling-app-pool-each-time-a-change-has-been-made-to-

    The umbraco install is version "umbraco v 4.7.1 (Assembly version: 1.0.4281.20201)"

    Could these two issues be related?

  • Rodion Novoselov 694 posts 859 karma points
    Feb 28, 2012 @ 13:31
    Rodion Novoselov
    0

    Hi, Daniel. It's rather strange at all that you need to recycle your pool after every change. Perhaps a real problem is here and not in your macro. I looks like your changes go to database smoothly but than for some reason aren't picked up by xml cache. Have you looked into the log for some errors happening after saving?

Please Sign in or register to post replies

Write your reply to:

Draft