Single element in detail custom template

Status
Not open for further replies.

Martooti

Member
I would like to customize details template by copying files from bootstrap folder and styling every element separately. I done this already for the list. I add every element with
Code:
<?php echo $this->_row->data->table___element_name;?>
How can I make this in details template files?
I read already the wiki tutorial but I didn't really get the answer there.
 
First clone the details template you wan to work from (bootstrap or bootstrap_tabs), by just copying the folder to a different name.

Then in default.php, you would probably want to strip out the 'foreach' loop that iterates through $this->groups, and replace it with your individual element placement.

Your element objects will be in $this->groups['group name']->elements[tablename___elementname]. So for convenience, assign a variable to use as shorthand for the element object like ... if you had a street_name element in a group called "Address"

Code:
$street_name_el = $this->groups['Address']->elements['yourtable___street_name'];

That is an object with various values, the important ones being 'element' and 'value'. Where$street_name_el->element will be the fully formatted element we would usually render, with the surround div, our classes, etc. And $street_name_el->value would just be the simple value of the element, with no formatting. So it sounds like you would want to use your own markup, and just insert $street_name_el->value.

-- hugh
 
Unfortunately I am making something wrong .
When I added in line 43 and 44 code:
PHP:
$datetimefb = $this->groups['Events']->elements['fb_events___date_time'];
echo $datetimefb->value;

I get:
Notice: Undefined index: fb_events___date_time in D:\xampp\htdocs\rsb2\components\com_fabrik\views\details\tmpl\events\default.php on line 43

Notice: Trying to get property of non-object in D:\xampp\htdocs\rsb2\components\com_fabrik\views\details\tmpl\events\default.php on line 44
 
I'm not sure if here the full element name is needed.
Try with $datetimefb = $this->groups['Events']->elements['date_time'];
 
Unforunately fblike and image elements doesn't show up properly. I think I should use other value than ->value, is that right?
Image show the path. Fblike only number.
I also would like company name to link to company details. The option in element window is checked but element doesn't link.
 
It may depend on the element type.
Do a var_dump($your-element);exit;
to see what is set where.
 
It show this
object(stdClass)#4195 (23) { ["startRow"]=> bool(true) ["endRow"]=> int(1) ["error"]=> string(0) "" ["plugin"]=> string(6) "fblike" ["hidden"]=> bool(false) ["id"]=> string(22) "fb_events___fb_like_ro" ["className"]=> string(28) "fb_el_fb_events___fb_like_ro" ["containerClass"]=> string(62) "fabrikElementContainer plg-fblike fb_el_fb_events___fb_like_ro" ["element"]=> string(522) "

" ["label_raw"]=> string(0) "" ["label"]=> string(6) " " ["errorTag"]=> string(40) "" ["element_ro"]=> string(107) "
->element make it work for facebook like
That was a great piece of knowledge to share, thank you Troester
 
I am trying to make use of fileupload element which allows to upload many files - images and videos. I would like that both kind of files are displayed smaller size on details view but on click opened with full size in lightbox. Unfortunatelly by defaulf video files are not included in the lightbox. (Is there a simple way to change it?)
I thought about accessing the files and making the custom code for this, but I do not know how to access single file that is stored in the array . Can someone advise something?
I try to make a vardump . I got something like:
Code:
object(stdClass)#1454 (23) { ["startRow"]=> bool(true) ["endRow"]=> int(1) ["error"]=> string(0) "" ["plugin"]=> string(10) "fileupload" ["hidden"]=> bool(false) ["id"]=> string(21) "fb_gallery___image_ro" ["className"]=> string(27) "fb_el_fb_gallery___image_ro" ["containerClass"]=> string(65) "fabrikElementContainer plg-fileupload fb_el_fb_gallery___image_ro" ["element"]=> string(1354) "
" ["label_raw"]=> string(13) "Image / Video" ["label"]=> string(91) "Image / Video" ["errorTag"]=> string(40) "" ["element_ro"]=> string(1316) "
" ["value"]=> array(2) { [0]=> string(40) "/images/gallery/hurghada-634054_1280.jpg" [1]=> string(82) "/images/gallery/ATC_-_All_Around_The_World__la_la_la_la_la_la_la_la__-_YouTube.mp4" } ["element_raw"]=> array(2) { [0]=> string(1) "6" [1]=> string(1) "7" } ["labels"]=> string(1) "0" ["dlabels"]=> string(1) "0" ["tipAbove"]=> string(0) "" ["tipBelow"]=> string(0) "" ["tipSide"]=> string(0) "" ["offset"]=> int(0) ["span"]=> string(7) " span12" ["column"]=> string(31) " style="clear:both;width:100%;""
 
As you can see ->value is an array containing the file pathes.
So something like

foreach ($your-element->value as $myfile) {
//do something with $myfile
}
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top