Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Get the number of item in an object array #281

Closed
papakay opened this issue Sep 2, 2016 · 1 comment
Closed

How to Get the number of item in an object array #281

papakay opened this issue Sep 2, 2016 · 1 comment

Comments

@papakay
Copy link

papakay commented Sep 2, 2016

Hello,

Please i have issue finding the number of item in an object returned. I have a object data as below

`public 'tags' =>

object(stdClass)[74]
  public '1' => 
    object(stdClass)[75]
      public 'id' => string '1' (length=1)
      public 'slug' => string 'fashion' (length=7)
      public 'name' => string 'Fashion' (length=7)
      public 'user_id' => string '1' (length=1)
      public 'published' => string '1' (length=1)
      public 'created_at' => null
      public 'modified_at' => null
      public 'uploads_count' => int 0
  public '3' => 
    object(stdClass)[76]
      public 'id' => string '3' (length=1)
      public 'slug' => string 'photographer' (length=12)
      public 'name' => string 'Photographer' (length=12)
      public 'user_id' => string '1' (length=1)
      public 'published' => string '1' (length=1)
      public 'created_at' => null
      public 'modified_at' => null
      public 'uploads_count' => int 0`

And in my smarty template, i have the code below

`{foreach from=$talent->tags item=tag}

                            {if $tag@total eq 1}
                                {*//do something*}
                            {else}
                                {if $tag@index lt 2}
                                    <a href="{base_url('talents/'|cat:$tag->slug)}" class="skill">{$tag->name}</a>
                                {/if}
                                {if $tag@index eq 2}
                                    &
                                    {break}
                                {/if}
                            {/if}
                        {/foreach}`

{$tag@total} returns 1 when items are more than 1. Please what i'm i doing wrong?

How can i resolve this?

Thank you.

uwetews added a commit that referenced this issue Sep 6, 2016
@uwetews
Copy link
Contributor

uwetews commented Sep 6, 2016

It was a bug which is now fixed in the master branch

@uwetews uwetews closed this as completed Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants