Copied to clipboard

Flag this post as spam?

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


  • James 251 posts 1169 karma points
    Oct 21, 2014 @ 15:13
    James
    0

    Generating a number for each child

    Hello All,

    I currently have a section on a website called "projects" the user can create under this "project" as many as they want.

    Is there a way forme to add a number for, or call the number of each project item.

    I just want it to go 1,2,3,4 for each project.

    So the user will have:

    Project 1 : Number 1

    Project 2 : Number 2

     

     

    This is so that when i do a foreach inside my page I can set the CSS classes to accordian-@projectnumber and they will therefore be unique.

     

    I dont want to use the ID if possible.

     

    Kind regards,

     

    James.

     

  • James 251 posts 1169 karma points
    Oct 21, 2014 @ 15:35
    James
    0

    Solved it.

    Just did:

    int number = 1;

    @foreach(){

    my html + css  then @number

    number = ++number;

    }

     

    Sorted.

     

    Thanks anyways guys.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 21, 2014 @ 16:19
    Dennis Aaen
    101

    Hi James,

    Super you solve it :-),

    Just want to say that another way that you could solve it is by this:

    @foreach (var item in projectItems){
        <h1>@item.Position() @item.Title</h1>
    }

    I have just made a dummy foreach loop. Then it will print the position that it has in the Umbraco backoffice.

    Maybe you can use it for future time.

    /Dennis

  • James 251 posts 1169 karma points
    Oct 21, 2014 @ 20:42
    James
    0

    Great ! Much simpler!

     

    Thanks Dennis.

Please Sign in or register to post replies

Write your reply to:

Draft