-
Notifications
You must be signed in to change notification settings - Fork 715
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
multidimensional array keys #254
Comments
Ok let me resume. I think its not a bug and we just made it wrong. Its either AS $name, or AS $k => $v. Accessing {foreach $templates as $template}
{templateBlock template=$template key=$template@key}
{/foreach} I'll close this for now. Sorry for the hassle. But there is one little question left. We don't need this in this case, but, is there a way to get the subarray key name (which is 'info' here, but could be something dynamically set) by the foreach command and loop only? {$template.info@key} or such does not work. |
…sed both the key variable was not updated #254
Indeed it was a bug that when a key variable and item@key both have been used the key variable was not updated. this is now fixed. $key and $item@key have the same meaning So I don't understand why item@key should show 'info'? |
OK thanks. That indeed returns to the behaviour before.
It should not and is not what I meant. Its ok for the main arrays key, but my question after all was about the inner subarrays key name. If there is a way to get this with foreach only... eg item.item@key or something. |
I still have problems to understand. |
Yeah, forget it :) |
3.1.30-dev/80
I have just found a strange sudden foreach issue. This definitely worked before, but I don't know which version broke this behaviour, or if I myself did something strange causing this.
<pre>{$templates|print_r}</pre>
is a key named array which includes another key named subarray.When I do this:
{$template}
is empty and the $info@key is the $template key. Before (with 3.1.30-dev/66) it was $template == foo and $info@key == foo ( strange though it was'nt 'info' for the 2cd)Normally we do this with it:
Again
{$template}
is empty,$info
is the sub array as ever,{$key}
is the $template name key.@uwetews Can you please have a look to it and confirm it working or buggy, or Smarty behaviour having changed... Thanks!
Edit: I just checked with an older 3.1.30-dev/66 which worked ok. So it may be a behaviour change in
@key
chaining or a bug. If being a behaviour change, I could use$key
instead of$template
though. In this case it should be noted somewhere, since it breaks custom k=>v usage. But I think it is a bug and somehow related to 0fcac38 or so. [Tested with PHP 5.6.23]The text was updated successfully, but these errors were encountered: