Page 1 of 1

[Resolved] Simplified all-in-one product listing

Posted: Wed Jun 26, 2013 5:48 am
by Dramatic
[Using Calguy1000's e-commerce modules]
I have a client with a total of seven products/services which fall under four hierarchy entries (single level). They would like everything to to be on one page, with the markup ending up something like:

Code: Select all

<h3>hierarchy name 1</h3>
<dl>
<dt><a href=product detail link>Product name 1</a></dt>
<dd>product summary 1</dd>
<dt><a href=product detail link>Product name 2</a></dt>
<dd>product summary 2</dd>
</dl>
<h3>hierarchy name 2</h3>
etc...
So far I've added a summary field to the products, and made a new hierarchy report template formatted as h3's and most other content removed. I figure that either there should be a call there to a product list template or just the smarty code for that template inserted directly, but I don't know what's necessary.
(note that all services are unpriced, as they're by quotation)

Can anyone point the way, or show me an example?

Re: Simplified all-in-one product listing

Posted: Sat Jul 06, 2013 8:34 pm
by Dramatic
I have achieved what i'm after, but by using a terrible kludge because i can't figure the syntax for directly displaying the value of a specific custom field 'Product_Summary' : {$entry->???}
(Or as described in the template comments 'the summary template has access to custom fields via the $entry->fields hash')

In the meantime i've pinched code from the detail template which enumerates all custom fields and bunged an {if} into it. Ugh!

Re: Simplified all-in-one product listing

Posted: Sat Jul 06, 2013 9:12 pm
by Jo Morg
Maybe this can help...
And this...
You may try {$entry->fields|print_r} or {$entry->fields|print_r} to see what is available on that particular template. :)

Re: Simplified all-in-one product listing

Posted: Mon Jul 08, 2013 10:40 am
by Dramatic

Code: Select all

{$entry|print_r}
gives me

[fields] => Array ( [Product_Summary] => stdClass Object ( [id] => 1 [name] => Product_Summary [prompt] => Product Summary [type] => textarea [options] => Array ( [] => ) [max_length] => 255 [value] => An online, self-paced version of our starting a business course. [fielddef_id] => 1 ) )

{$entry->Product_Summary.value} ?

Re: Simplified all-in-one product listing

Posted: Mon Jul 08, 2013 11:44 am
by webform
Try

Code: Select all

{$entry->fields.Product_Summary->value}

Re: Simplified all-in-one product listing

Posted: Mon Jul 08, 2013 3:06 pm
by calguy1000
$entry is an object. You access its elements with ->
[fields] => Array
means that 'fields' is an array. you access its elements with a . (or you could use a foreach)

i.e: {$entry->fields.SOMETHING}
[Product_Summary] => stdClass Object
means that Product_Summary is an object, you access its members/methods with a ->

i.e: Product_Summary->SOMETHING}

following that is a list of the members of Product_Summary which may in themselves be strings, integers, arrays, objects, etc. 'value' is a string, member of the Product_Summary object. so it doesn't need further digging.

Putting it all together:

{$entry->fields.Product_Summary->value} should give you what you want.

Re: Simplified all-in-one product listing

Posted: Tue Jul 09, 2013 12:18 am
by Dramatic
Thanks - I need to do OOP 101 :)