• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Div template combine rows

jh

Member
Hi

I wanted to combine 2 elements on one row on the div template I am using.
1 of the elements is using replace with icons.

I have tried to use calc to combine these 2 elements and although it does return the correct values, the element using replace icons does not work (I assume this is because there is no actual value in the db).

Is there a way of making this work, or will my only choice be to customise a list template to combine 2 fields into one row - also is this actually possible?

Thank you for any advice.

Kind Regards
 
I assume this is for only one pair of elements, not for all of them.

...no actual value in the db.
A calc element will have its value stored in the DB if you configure it to do so. Please refer to your previous post and the Wiki.

Then, if you have configured "Replace with icon" for the calc element, it may work or not. Best try.

If it doesn't go the way you want, you have several other options:
- In the calc element, use PHP "if {} elseif {} else {}" to return whatever you want depending on conditions such as element values.
- Or instead of using a calc element: since frontend rendering is basically the result of the default behaviour of HTML plus CSS, you may use CSS or Javascript to bring "vertically neighbouring" elements onto "the same line". The fact that Fabrik applies dedicated IDs and classes to each element is extremely helpful.
- Or, indeed, override template/layouts or create your own template based on an existing one. Again, the Wiki comes to help: http://fabrikar.com/forums/index.php?wiki/creating-a-custom-list-template/
 
Hi

Thanks for your reply. I think customising the list template is the best option as I might make some other changes to. I have looked at the wiki which is very helpful but I had a few stumbling points I wondered if you could kindly help me with?

I have started to customise 'default_row.php' by removing


"<?php if (isset($this->showLabels) && $this->showLabels) :
echo '<span class="muted ' . $h['class'] . '" ' . $hStyle . '>' . $label . ': </span>';
endif; ?>

<?php echo '<span class="' . $c['class'] . '" ' . $cStyle . '>' . $d . '</span>'; ?>"

and inserting fields by using eg:
"<?php echo $this->_row->data->pat_table___pat_name;?>"

This seems to be returning the value but I am not sure if this is the correct method? Namely if this is how to put the values into divs etc?
I get the feeling perhaps the field value should be coded somewhere into 'default.php' instead but I am just making a guess.
Also the method I am trying is returning the value, but many times over instead of just once, which I assume is because of some code somewhere else on the template.

Thank you for your assistance as I know my knowledge is somewhat limited.

Kind Regards
 
Obviously you're on the right way, and you're using the correct way of displaying elements' values. :)

Note that in default_row.php you have a "foreach" loop which iterates through all elements of a row. Means that if you echo a specific element value inside this loop (like you're seemingly doing with your example), it'll be displayed as many times as the loop is running. So, when echoing specific elements, you want to stay outside the "foreach" loop. Actually, for your purposes you may want to consider dropping the loop all together and, instead, building your own "row" structure based on your own HTML and content from values.

Don't forget that in default_row.php you can always take a look at what you're having available regarding element data with a var_dump or print_r of $this->_row->data.
 
Hi

Sorry to bother you again, but I dont seem to be able to move the 'thumbs' element correctly in this way. It shows the icon and count correctly but does not do any action when pressed (actually it looks like it might reload the whole page, but with no changes).

Im currently using:
"<?php echo $this->_row->data->pat_table___like;?>"

and have tried tweeking it a bit but to no luck.

Could you kindly offer some assistance?

Kind Regards
 
Hi

Ive been trying this out some more and have tried various methods to get the 2 elements on the same line just by using css on the original template (not my customised one). No matter what I try I can not seem to get 2 elements on one line. I have tried float and inline block but can not do it. Can it actually be done this way, and if so can someone kindly point me in the right direction.

Many thanks
 
Ive been trying this out some more and have tried various methods to get the 2 elements on the same line just by using css on the original template (not my customised one). No matter what I try I can not seem to get 2 elements on one line. I have tried float and inline block but can not do it. Can it actually be done this way, and if so can someone kindly point me in the right direction.

Nope, with the default bootstrap detail template and "CSS only" it can't be done in any practical way.

Thought you were already on the way of building your own template? IMHO, you should continue this route. What's made you abandoning it?
If it's the thumbs element as you mentioned previously: I've never used it, but of course you should be able to have it working in your custom detail template as well. As stated before, do a print_r, and then you'll be able to see and try which PHP variable will work.
 
Thank you, it was the thumbs element that was causing me some problems so I was going down a different route! Thanks for your advice, will keep trying to get the thumbs working properly on my custom template - my experience is pretty limited and Im having to learn a lot, so thanks for your help!
 
Hi

Ive just had a quick check with firebug and it looks like the template I have worked on removes the script from the button so no event is run. Would you know how I can get the script to work in my custom template?

Thank you for your time.
 
Ha, I was just going to say that you should keep eyes open for JS errors which could prevent the thumbs element from working.

If this or what you're indicating here is the case but without seeing what exactly you're doing, I guess the only advice is for you to carefully review your customisations e.g. by comparing with default template files. Or eventually start over in "one small step at a time" fashion, so you're able to figure out what went wrong immediately when it went wrong.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top