Copied to clipboard

Flag this post as spam?

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


  • Ioannis Gkoutsidis 16 posts 67 karma points
    Feb 10, 2013 @ 20:11
    Ioannis Gkoutsidis
    0

    Macro Stopped Working After Upgrading to Version 6.0.0

     

    Hi all,

    below is a piece of code I use to get some Facebook albums presented in my website:

     int i = 0;
     <div class="grid-content-940">
      @foreach (Album album in Facebook.GetAlbums(facebookUserID))
      {
       var testAlbumID = @album.ID;
       if (!excludedAlbums.Contains(testAlbumID))
       {
        i++;
        <div class="grid-content-220">
         <div class="album-row-holder">
          <div class="album-box-out">
           <div class="album-box-in">
            <a href="/portfolio/album/@album.ID">
             <img src="@CreateThumbnail(@album.CoverPhoto, 174, 118)" alt="@album.Name" />
            </a>
           </div>
          </div>
         </div>
         <div class="read-more">
          <a href="/albumid/@album.ID">@album.Name</a>&nbsp;[@album.Count]
         </div>
        </div>
        if ((i % 4) == 0) { <div class="grid-separator-row"></div> }
        else { <div class="grid-separator-18"></div> }
       }
      }
     </div>

    While the code above works on a 4.11.4 test installation, I cannot make it work on a 6.0.0 installation. The parser keeps telling me that a } is expected. The weird thing is that if I comment the if statement in line 6 with the respective {} braces in lines 7 & 25, everything works fine!

    Any ideas?

    Thanks in advance,

     

  • Charles Afford 1163 posts 1709 karma points
    Feb 10, 2013 @ 20:18
    Charles Afford
    0

    Hi, what language are you using?  surely

    if(!excludedAlbums.Contains(testAlbumID))

    {

    HTML MARKUP

    }

    is going to through an error?

    Charlie :)

  • Steven Lemmens 30 posts 71 karma points
    Feb 10, 2013 @ 22:24
    Steven Lemmens
    0

    Have you tried putting an explicit @ in front of the "if ((i % 4) ..." part to make sure it parses as code again?

  • Ioannis Gkoutsidis 16 posts 67 karma points
    Feb 11, 2013 @ 09:09
    Ioannis Gkoutsidis
    0

    Hi all,

    @Charles Afford: I know that using such spaghetti code, is not the best approach, but right now it's the best we can do...! As I've already mentioned, the code above works fine in Umbraco 4.11.4. 

    @Steven Lemmens: I tried the modification suggested, but it gives me the following error:

    Unexpected "if" keyword after "@" character. Once inside code, you do not need to prefix constructs like "if" with "@".

    I really have no idea what's going on, but I'd like to thank you all for your help.

  • Ioannis Gkoutsidis 16 posts 67 karma points
    Feb 11, 2013 @ 19:47
    Ioannis Gkoutsidis
    100

    Hello again,

    after some digging and testing, I decided to move the "exclusion" login into my assembly, so now the "GetAlbums" function includes the "if" statement.
    The code gets saved correctly and the macro runs with no problem.

    Thanks a lot again, all of you! 

  • Charles Afford 1163 posts 1709 karma points
    Feb 11, 2013 @ 21:08
    Charles Afford
    0

    Ioannis.  i understand, it depends what you are doing it for.?  The problem you will run into is builiding layers on top of that spag code, that will not be easy if at all possible to undo in the future.  Any how i am glad you solved your problem :) Charles.

  • Matthias 87 posts 173 karma points
    Feb 12, 2013 @ 10:23
    Matthias
    0

    Hi,

    i had this issue too when moving from 4.11.3 to 6.0.0. Many Razor scripts were throwing errors like you mentioned.
    Version 6.0.0 handles the "@" sign very sensitively ;-)

    It could be this line:

    var testAlbumID =@album.ID;

    Try to leave the "@" here.

    var testAlbumID =album.ID;

     

    Matthias

  • Ioannis Gkoutsidis 16 posts 67 karma points
    Feb 13, 2013 @ 08:41
    Ioannis Gkoutsidis
    0

    Hi all,

    although I have moved the exclusion logic into my assembly I tried Matthias's solution and it really works!

    As he said the @ sign is handled very sensitively...

    Anyway, thanks again all of you!

  • Matthias 87 posts 173 karma points
    Feb 13, 2013 @ 09:07
    Matthias
    0

    Some background information:
    the change was mentioned in this blog post: "...The upgrade to MVC4 and therefore Razor 2.0 leads to stricter checking of misplaced @ signs. For details, issue 1143."

Please Sign in or register to post replies

Write your reply to:

Draft