ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

{exp:file:entries} count

September 01, 2011 12:34am

Subscribe [3]
  • #1 / Sep 01, 2011 12:34am

    Ryan

    31 posts

    I’m having trouble outputting the {count} for each entry output;

    {exp:file:entries directory_id="1"}
        {if viewable_image}<li id="image_{count}">{file_url}</li>{/if}
    {/exp:file:entries}

    The problem is each <li> is being returned with the ID image_1, isn’t this supposed to be incremental?

    On a related note, in the File Manager (v2.2.2) the “Upload File” link href is blank and just reloads the page for me.

    I thought it used to display the “Upload File” popup form.

  • #2 / Sep 01, 2011 11:37am

    Sue Crocker

    26054 posts

    Hi Josephs,

    The problem with the File Manager not displaying is a known bug, you can find a workaround for it at:

    https://support.ellislab.com/bugs/detail/16322/

    I can’t replicate the problem you were having—see the attached partial screen shot.

  • #3 / Sep 01, 2011 11:42am

    Ryan

    31 posts

    I can’t replicate the problem you were having—see the attached partial screen shot.

    Thanks for confirming that Sue, I’ve realised the problem is with my code.

    The {exp:file:entries} pair is inside a {exp:channel:entries} pair, hence {count} is referencing the channel and not the files.

    I had done this is because of a conditional; to display {exp:file:entries} whether a value in {exp:channel:entries} is set.

    {exp:channel:entries channel="example" limit="1"}
        {if files}
            <ul>
            {exp:file:entries directory_id="1"}
                {if viewable_image}<li id="image_{count}">{file_url}</li>{/if}
            {/exp:file:entries} 
            </ul>
        {/if}
    {/exp:channel:entries}

    Any idea how I can separate the two and still have the condition?

  • #4 / Sep 02, 2011 12:55am

    Dan Decker

    7338 posts

    Josephs,

    You could try replacing {count} with {entry_id}

    {if viewable_image}<li id="image_{entry_id}">{file_url}</li>{/if}

    That would still give you a unique id for each image.

    Cheers,

  • #5 / Sep 02, 2011 6:13am

    Ryan

    31 posts

    You could try replacing {count} with {entry_id}. That would still give you a unique id for each image.

    Bah, {entry_id} seems to be a {exp:channel:entries} variable too :down:

  • #6 / Sep 02, 2011 3:01pm

    Lisa Wess

    20502 posts

    Hi, Josephs -

    did you try embedding the file entries tag to avoid the variable conflict?

  • #7 / Sep 02, 2011 8:36pm

    Ryan

    31 posts

    Did you try embedding the file entries tag to avoid the variable conflict?

    Hi Lisa, no I actually noticed that in the {exp:file:entries} tag, I’m actually setting the directory_id with a variable from {exp:channel:entries} as well.

    Plus I needed the conditional from {exp:channel:entries} as well.

    This isn’t the first time this has happened, like for example with {exp:comment:entries}  I’ve wanted to use {exp:channel:entries} {if allow_comments} conditional, and have not found a way to separate the tag pairs.

    Fortunately with the {exp:file:entries}, this time I was able to achieve what I needed with a different method; using jQuery!

  • #8 / Sep 02, 2011 9:33pm

    Lisa Wess

    20502 posts

    You would need to pass the directory_id through the embed.  Then you can embed and avoid the problems you are running into.  Make sense?  So:

    {embed='blah/blah' my_var="3"}

    then in the calling template:

    {exp:file:entries directory_id="{my_var}"}
  • #9 / Sep 08, 2011 1:14am

    Ryan

    31 posts

    You would need to pass the directory_id through the embed.

    Thanks Lisa, I’m using an embed now. I thought I tried this before, but I must have missed something!

  • #10 / Sep 08, 2011 11:46am

    Lisa Wess

    20502 posts

    Glad you got it working, Josephs!  if you do have anything else come up, please let us know and we can help out.

    Thank you!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases