Page 1 of 1

How Can I get value from Dimensions type

Posted: Mon Nov 11, 2013 10:17 pm
by angelpeace
In this Products Detail Template
I have:
....
[fields] => Array
(
[Dimensions] => stdClass Object
(
[id] => 9
[name] => Dimensions
[prompt] => Dimensions
[type] => dimensions
[options] => Array
(
[] =>
)

[max_length] => 255
[value] => Array
(
[length] => 27
[width] => 17
[height] => 28
)

[fielddef_id] => 9
)
...
Get length or width or height????
Help me./

Re: How Can I get value from Dimensions type

Posted: Mon Nov 11, 2013 10:28 pm
by calguy1000
{$fields.Dimensions->value.length}

Re: How Can I get value from Dimensions type

Posted: Mon Nov 11, 2013 10:42 pm
by calguy1000
Here's the lesson:

$entry is an object. You access its elements with the -> operator. One of those members is 'fields' {$entry->fields} will return that member.

Code: Select all

[fields] => Array
means that the field member itself is an array. that you access its elements with the . or [] operators (see the smarty manual). One of those members is 'Dimensions'
so {$entry->fields.Dimensions} will return that element

Code: Select all

[Dimensions] => stdClass Object
means that the Dimensions element is itself an object. You access it's members with ->

One of the members of the Dimensions object is 'value'. so {$entry->fields.Dimensions->value} will return that member.

Code: Select all

[value] => Array
means that the value member of the Dimensions object is itself an array. Again, you access the array elements with . or [] operators.

One of the elements of the Value array is 'length'.
so {$entry->fields.Dimensions->value.length} will return that element

Re: How Can I get value from Dimensions type

Posted: Mon Nov 11, 2013 10:42 pm
by angelpeace
Thanks,

{if ($field->type == 'dimensions')}
{assign var="length" value=$field->value.length}
{assign var="width" value=$field->value.width}
{assign var="height" value=$field->value.height}
{/if}

Re: How Can I get value from Dimensions type

Posted: Mon Nov 11, 2013 10:47 pm
by angelpeace
Hey Calguy,
I want to know Two type defination on Products: Subcriptions & Quantity on hand;
For example?? I don't use.