Copied to clipboard

Flag this post as spam?

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


  • Nick 101 posts 123 karma points
    Apr 01, 2012 @ 11:29
    Nick
    0

    dynamic variables are broken in Umbraco 4.7.1

    Hi guys, hope you can help me with this.

    Recently I deployed a new project on the same server as some older ones and it seems all dynamic variables are blank, as if something went terribly wrong in the configuration of the project. Everything else works fine, except all dynamic variables being blank.


    Has anyone seen this before? I have no idea where to look to fix it without deleting everything and redeploying from scratch.

    For example if I add a bool property in the document type previously I was able to use that in a macro by saying 

    if (item.MyProperty) {...}

    Now it's always empty. Same thing if I try (item.GetProperty("MyProperty") and also same for all macro parameters.

    About to go insane here, has anyone else seen this problem? Is it common?
    My deployment steps were identical to the other 3 Umbraco projects and on the same server and the others work fine. First time I experience such a problem and it makes it impossible to work.

    Any help is greately appreciated
    Many thanks in advance

    Nick

  • lucuma 261 posts 563 karma points
    Apr 03, 2012 @ 16:25
    lucuma
    0

    Have you tried republishing the entire site?

  • Grant Thomas 291 posts 324 karma points
    Apr 03, 2012 @ 16:28
    Grant Thomas
    0

    Lucuma, care to elaborate on why that might actually help?

    Forgive me, but in my opinion this is half of the issue when using Umbraco: endless suggestions of differing processes with no explanation as to the underlying cause and effect. Sometimes a suggestion will work, but if my GP prescribed me drugs without a diagnosis then it becomes problematic.

    I have a feeling you're referring to the pages that are published don't contain, within their reivision (of that cache instance?), the key/values for the variables, and the dynamic lookup won't complain that they don't exist when trying to access them -  and that republishing everything ought to push the references to these properties into the current revision. However, I'm not sure how this stands re relevancy to the OPs predicament, since these are existing properties (I think). But either way this doesn't really negate my point above.

  • lucuma 261 posts 563 karma points
    Apr 03, 2012 @ 16:32
    lucuma
    0

    I've had tons of issues when I've copied projects (made changes or what not) or uploaded projects to a different server with regards to having empty data.  Typically after republishing, the cache gets updated and the site works properly.

    Grant, you can address that with the Umbraco folks.. It isn't my job to technically evaluate the issue, go into depth with an answer, and fully troubleshoot the issue but you are more than welcome to.

  • Grant Thomas 291 posts 324 karma points
    Apr 03, 2012 @ 16:48
    Grant Thomas
    0

    Isn't the cache local? As in, file-wise, it resides somewhere within/under the folder that would be copied? Or is it exclusively a context only, memory cache?

    If local then that might explain it, but I'm not sure the of the logic behind caching to files over retreiving from a database (i.e. an optimised file). If in memory then that ought to rebuild when that memory doesn't contain a cache. A republish might work, but I'd still be very curious as to why.

  • lucuma 261 posts 563 karma points
    Apr 03, 2012 @ 16:53
    lucuma
    0

    The cache is local inside the app_data folder as far as I know.

  • Nick 101 posts 123 karma points
    Apr 03, 2012 @ 16:58
    Nick
    0

    Ok in the Macro parameters I have "Cache by page" to false and the caching period set to 0 seconds.


    If I make an alteration to the macro, save and refresh the page, the alteration takes place immediately so the latest version of the macro is always getting picked up. 

    My dynamic properties are coming up but the Macro parameters are always empty in any template I've tried.
    I've tried going through the debug info, macro is registered succesfully, nothing odd there.

    I am currently developing without any parameters but it's really difficult. 

  • lucuma 261 posts 563 karma points
    Apr 03, 2012 @ 17:04
    lucuma
    0

    If you want, paste the code where you are calling the macro, a screenshot of the macro setup (the parems), and the code for your actual macro.  That would probably help.

  • Nick 101 posts 123 karma points
    Apr 03, 2012 @ 17:25
    Nick
    0

    Well the macro (and all my macros generally) work well so I'm sure the problem isn't with the macro.

    I write this:

    <umbraco:Macro Alias="Test" runat="server" Nick="foo"></umbraco:Macro>  

    and in the macro itself:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{  
      @Parameter.Nick
    }  

    In another project I have this prints "foo". But in this one ALL of my parameters are always null... as if they don't exist.

    If you can help me with some way of debugging this, I would be very grateful. Perhaps a way to loop through the parameters or something... 

  • lucuma 261 posts 563 karma points
    Apr 03, 2012 @ 17:29
    lucuma
    0

    Did you setup the parameters on the actual macro?  

    http://screencast.com/t/ef2Br5i6R1Jc

  • Nick 101 posts 123 karma points
    Apr 03, 2012 @ 17:36
    Nick
    0

    Actually, I hadn't because in my previous project I can just add any parameter on the macro and it just gets picked up automatically.

    However, I added the parameter now and there is no difference. It still doesn't get picked up.

    I have the check box that says "show" ticked, and a text parameter of Alias "Nick" and name "Nick".

    Is there another way of grabbing a parameter? Something that will force it? Maybe GetParameter?

    Nick 

  • lucuma 261 posts 563 karma points
    Apr 03, 2012 @ 17:38
    lucuma
    0

    I think you are missing the using umbraco.MacroEngines.. Here is an example of one of mine:

     

    @using umbraco;
    @using System;
    @using System.Collections.Generic;
    @using umbraco.MacroEngines;
    @inherits umbraco.MacroEngines.DynamicNodeContext


    @{
        String mediaType String.IsNullOrEmpty(Parameter.MediaType"BlogPost" Parameter.MediaType;

    }

  • Nick 101 posts 123 karma points
    Apr 03, 2012 @ 17:44
    Nick
    0

    This worked!!!

    @using umbraco;
    @using System;
    @using System.Collections.Generic;
    @using umbraco.MacroEngines;
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{  
      @Parameter.Nick
    }

    Thank you very much for helping me find what was wrong with this.

    What is odd is that I never needed to include these in my other projects, but perhaps the web.config is different.
     
    Again, many thanks 

  • lucuma 261 posts 563 karma points
    Apr 03, 2012 @ 17:46
    lucuma
    0

    I believe you just need the umbraco.MacroEngines.. My particular macro used all of them and I just copied and pasted..  Glad it works for you.

Please Sign in or register to post replies

Write your reply to:

Draft