Copied to clipboard

Flag this post as spam?

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


  • Kim Andersen 1447 posts 2196 karma points MVP
    Jan 29, 2012 @ 00:20
    Kim Andersen
    0

    v5: Possible to loop over x properties with almost same alias

    On a site of ours, we want to be able to insert related information in right side of the page, using content pickers. So we have created three content pickers (called relatedInfo1, relatedInfo2 and relatedInfo3 as their aliases) on the main cod types, where it's possible to select three other nodes.

    When selecting a node in eg. the first picker, the code must render the title of that node, on the page where it was selected.

    All of the three content pickers must be rendered with the same layoutand grab the same fields from the selcted nodes.

    So right now I actually have three pieces of the excact same code, to render the three "boxes".

    Is it possible to create a loop running three times, and for each of the times render some contet of the selected node based on the alias.

    Actually I'm trying to create some more flexible  codeinstead of having three snippets, where the only difference is the alias of the property.

    I know that I can create a loop running three times like this:

    for (int i=1; i<=3; i++)

    And then i will contain either the number 1, 2 or 3.

    I'm grabbing the content of a picker like this:

    Umbraco.GetEntityById(HiveId.Parse((string)DynamicModel.relatedInfo1));

    So could be cool if I could do something like:

    Umbraco.GetEntityById(HiveId.Parse((string)DynamicModel.rightComponent + i));

    or something like that so I could reuse my code.

    Any suggestions?

    Thanks...

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft