How to make a detailed view template?

As I understand there is a template for lists and forms respectively, but none for the detailed view - the form template is used instead.
I have used the custom form template (//very well documented) to show a detailed view of each of my products.
The structure is to show each groups, in consecutive order and then each element in the group by element-name.
(Please correct me if I?m wrong)
As the design of my detailed view do not follow a consecutive order, I use next/prev group to shuffle between the elements I want to show.
The disadvantage to this is when groups are rearranged, deleted or added ? I must alter my template accordingly.
Is it possible to make a detailed view template where group and element are called interconnected?
 
You can use f3.1. I have read somewhere that in f3.1 you can have separate form view and detailed view template.
 
The element objects are in $this->data as well as the group elements array, indexed by the element id. So $this->data['foo___bar'] is an object, where $this->data[foo___bar']->element is the element input markup, ->label is the label, etc.

So you should be able to use that to build a non-sequential template.

Note however that our JS sometimes relies on the DOM structure of the group wrapper, although that shouldn't be a problem in a detail view.

-- hugh
 
As I understand there is a template for lists and forms respectively, but none for the detailed view - the form template is used instead.
You can select different templates for form and details view. So in Fabrik3.0 just create your details template and put it into the ...components\com_fabrik\views\form\tmpl folder.
 
Hi troester,
Thanks! I've done this already and use the custom_contact template modified to my needs.
(Just don't get the idea to have a template folder for detailed views that points to forms?)

Hi cheesegrits, - sorry but I don't quite get it.
Can you provide me with an example on how to make this non-sequential?
My group is: PlanetsPride_Item (ID19)
My element is: PlanetsPride_Item___Description (ID363)

Present code (shuffle between groups):
<?php
$this->group = next($this->groups);
$this->elements = $this->group->elements;
?>
<?php
$this->element = $this->elements['Description'];
echo $this->loadTemplate('element');
?>
<?php
$this->group = prev($this->groups);
$this->elements = $this->group->elements;
?>
<?php
$this->element = . . . . . .etc
 
$this->groups is keyed on the group label I believe (poor choice now that I think about it but its not possible to change without breaking backwards compat) - so you can grab those by doing

PHP:
echo "<pre>";print_r(array_keys($this->groups));echo "</pre>;

that would dump out an array of the group keys, say :

Code:
array('My first group', 'my second group');

(Once you've made a note of that array you can remove/comment out the print_r statement from the template)

then to get the group:
PHP:
$myFirstGroup = $this->groups['My first group'];
$this->elements = $myFirstGroup->elements;
$this->element = $this->elements['Description'];
echo $this->loadTemplate('element');
 
rob - I think it's time we at least started moving towards a saner way of keying the groups. Even if we just provide a $this->groups_by_id, and don't use it for now.

You may recall that in 2.x I had to add some nasty defensive code to generate automatic names, if they didn't give a name in the group settings (it's not a required field), to avoid having blank array key(s). I think I also added a hack in 2.x to add a suffix if someone has the same name twice.

As you say, it's hard to fix, but I think if we at least create the $groups_by_id, as we move forward we can start modifying our templates to use it, as long as we retain the original $this->groups (by name), so old / custom templates continue to work.

Yay? Nay?

-- hugh
 
Thanks Rob,
For me as a first class student in PHP you managed to explain a solution that I could actually understand ? I tip my hat!
Thank you for your help.

I do agree though that the id should be the key and leave one the option to rename the group.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top