Language tag issue in list related data - Button text

Thanks - I'll take a look but should be easy to fix.

P.S. Looking at the code I see that the List Heading field is translated in a list (as your example suggests) but not when in a form, and that the equivalent form fields are also inconsistent in whether they are translated. So we might as well fix these at the same time.
 
Last edited:
Indeed, it should be easy enough for you to fix if you wanted to take a shot with some guidance from me - and start to learn how to fix these things yourself?
 
Ok - the work you need to do comes in two parts:

a. Finding the code and fixing it.
b. Submitting your fixes through Github - there is a Wiki page about contributing via Github if you need it, but if you still need help please ask.

So, finding and fixing the code.

1. Right click in one of the List Button boxes and select Inspect Element. This will show you something like:
Code:
<input
    type="text"
    name="jform[params][facetedlinks][linkedlisttext][18-19-409]"
    value=""
    size="16"
    aria-invalid="false">
The bit we are interested in is the id or (in this case) name attribute. The numbers at the end indicate what related data it is referring to - for instance the 18 is the list it refers to. The bit we are interested in is "linkedlisttext".

So now we need to find where in Fabrik this text is used. (I have use GitHub for Windows and have a local copy of Fabrik, and I have indexed the contents with Windows Search so finding where this text appears is easy - but you can also do a search on Github.) I find that "linkedlisttext" is in two files:
  • administrator/components/com_fabrik/models/fields/facetedlinks.php
  • components/com_fabrik/models/list.php
The first of these relates to the admin screen where you input the text (i.e. where your screen shot is), so we are interested in the second one. If we look in that file and search for the text we find the following code block at line 2155:
Code:
$linkedListText = isset($faceted->linkedlisttext->$elKey) ? $faceted->linkedlisttext->$elKey : '';
$row2 = ArrayHelper::fromObject($row);
$label = $this->parseMessageForRowHolder($linkedListText, $row2);

What we should see is a call to the Fabrik / Joomla routine that translates language strings "FText::_(variable)" - but it is not there. So the correction for this code is to add it to the first line:
Code:
$linkedListText = isset($faceted->linkedlisttext->$elKey) ? FText::_($faceted->linkedlisttext->$elKey) : '';

Now we do the same for the List Heading box:
Code:
<input name="jform[params][facetedlinks][linkedlistheader][18-19-409]" ...>
We find that "linkedlistheader" is in three files:
  • administrator/components/com_fabrik/models/fields/facetedlinks.php (again)
  • components/com_fabrik/models/form.php
  • components/com_fabrik/models/list.php (again)
In components/com_fabrik/models/list.php at line 7025 we have:
Code:
$heading = $faceted->linkedlistheader->$key;
if ($linkedTable != '0' && $facetTable->canView())
{
    $prefix = $join->element_id . '___' . $linkedTable . '_list_heading';
    $aTableHeadings[$prefix] = empty($heading) ? $join->listlabel . ' ' . FText::_('COM_FABRIK_LIST') : FText::_($heading);
    $headingClass[$prefix] = array('class' => 'fabrik_ordercell related ' . $prefix,
            'style' => '');
    $cellClass[$prefix] = array('class' => $prefix . ' fabrik_element related');
}
and we can see that the text is put into $heading and then when $heading is used it is translated. But in components/com_fabrik/models/form.php line 4414 we see it isn't:
Code:
$label = $facetedLinks->linkedlistheader->$key == '' ? $element->listlabel : $facetedLinks->linkedlistheader->$key;
$links[$element->list_id][] = $label . ': ' . $referringTable->viewDataLink($popUpLink, $element, null, $linkKey, $val, $count, $f);
So again we need to add "FText::_()":
Code:
$label = $facetedLinks->linkedlistheader->$key == '' ? $element->listlabel : FText::_($facetedLinks->linkedlistheader->$key);

Then we do the same for the equivalent form fields: "linkedformheader" and "linkedformtext".

See, when the fix is as easy as "FText::_()" fixing it is not so hard.

What I do is to make the changes and test them in my own site. Then when I have them working I submit the same changes as a PR to Github so that they (hopefully) get merged into the Fabrik base and so the next time I update from Github my changes will not disappear.

Let me know how you get on - and if you need help with submitting a PR Github after reading the wiki page, please ask.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top