Typo3 Translations in Extbase not working with inline relations - localization

i created an extension which uses a main controller which could add inline relations.
I`m using Typo3 11.
If I translate the relations, but not the main Entry, also the language of the already translated relation is the default one.
It doesnt matter, if i set the language to "all", the result is still the same.
I really have to translate the main entry to the other language althought its not necessary.
Is there a way to resolve this issue?

There is a simple rule of thumb: Only use language "all" for parent elements that contain only child elements which should be visible in "all" languages too.
As soon as there should be translated children, you should translate the parent element first and usually pick "connected mode", which will give the default language the lead over the target language behaviour.
If there are differences between the number of different child elements and/or there are child elements in a target language, which don't exist in the default language, you should go for "free mode" translations instead.
So actually there is no "although its not necessary" in your case.

I dont know the reason why, but if I integrated a "foreach" over my "missingTranslationArray" inline IRRE, at the top of my Template the translation is shown.
It doesnt matter that the foreach doesn't make sense inside my template, but now the missing translations are shown.
<f:for each="{myMissingTranslations}" as="myMissingTranslation"></f:for>
For me that helps, but i have no answer why its necessary.

For all who have the same problem, now I`ve got a solution.
Rewrite the "showAction" inside the controller like:
From:
/**
* action show
*
* #param \VENDOR\myExtension\Domain\Model\controller $controller
* #return void
*/
public function showAction(\VENDOR\myExtension\Domain\Model\controller $controller)
{
To:
/**
* action show
*
* #return void
*/
public function showAction()
{
And submit just the "uid". Inside the controller use the "findbyuid" repository for the entry.
$id = $this->request->getArguments('entry');
$entry = $this->entryRepository->findByUid($id['entry']);
$this->view->assign('entries', $entry);
The empty repository for each inside the template is also necessary. For that renders every repository inside every single action.
i.e.:
<f:for each="{myRelation1}" as="myRelation1"></f:for>
<f:for each="{myRelation2}" as="myRelation2"></f:for>

Related

Return Filtered Module in DXL

I need to make a filter in certain Module and get the filtered items and loop over them and do some kind of operation.
problem is filtering isn't done , something is wrong as follows :
Filter SwTest = includes(attribute "aVerificationStrategy" ,"SwTest")
Filter Implemented = (attribute "aObjectStatus" < "inReview")
Filter SwTestReqsCASTLE = SwTest && Implemented
Module m = srs_doc
set(m, SwTestReqsCASTLE, accepted , rejected)
filtering on OR ApplyFiltering(m) , i tried each as don't know difference !
so what is wrong ?
Before I answer your main question, first allow me to answer your implied question about the difference between "filtering on" and "ApplyFiltering(m)". The difference is that "filtering on" displays the current filter in the module window, meaning that objects are either shown or hidden depending on the filter. "ApplyFiltering(m)" applies the current filter settings to the module explorer (the area to the left of your objects that shows the hierarchy). "filtering on" shows and hides objects and "ApplyFiltering(m)" reflects the status of those objects in the module explorer.
As for why your filters are not being applied, there could be several reasons:
It is good practice to turn filtering off before you start setting filters. Add the line "filtering off" before the rest of your code.
Your "Implemented" filter is not defined properly. DOORS will see "inReview" as a string, and it will perform a direct comparison with the string value of your "aObjectStatus" attribute in order to determine if an object is accepted or rejected. Is this what you intended?
What type of variable is srs_doc? If it's a string then you need to
call read(), share(), or edit() in order to actually open the
module. If it is a module variable then that line is correct.
I am assuming that "accepted" and "rejected" are integers, but if they are not previously declared then they need to be.
Based on the first paragraph in my comment, your last line should read "filtering on"
Is the module you want to filter being displayed? I realize this is probably obvious, but I have made this mistake before so I thought I should mention it. A filter cannot be applied on a module that is not currently being displayed.
As a side note, you can compound your SwTest and Implemented filters without creating extra Filter variables as follows:
Filter SwTestReqsCASTLE = includes(attribute "aVerificationStrategy", "SwTest") && (attribute "aObjectStatus" < "inReview")
I hope some of that helps! Good luck, and let me know if none of the above solves your problem.

how to track the social media icons using DTM (Dynamic tag manager)

I have the below code in my web site.
I want to track each anchor tag using DTM. I know how to track single element. Since here we have a bunch of different elements, can anyone help how to track them using DTM? I don't want to create separate rule for each element. In a single rule how can we track these elements.
Here is an example of what you can do.
For Element Tag or Selector put "a.at-share-btn" (no quotes). This will target all the relevant links first. We can look for this too in the next step, but "pre-qualifying" it with this will improve performance so that the rule is not evaluated against every single a click.
Then, under Rule Conditions, add a Criteria of type Data > Custom.
In the Custom box, add the following:
var shareType = this.getAttribute('class').match(/\bat-svc-([a-z_-]+)/i);
if (shareType&&shareType[1]) {
_satellite.setVar('shareType',shareType[1]);
return true;
}
return false;
This code looks for the class (e.g. "at-svc-facebook") and puts the last part of it (e.g. "facebook") into a data element named shareType.
Then, you can reference it using %shareType% in any of the DTM fields. Note: because this data element is made on-the-fly, it will not show up in the auto-complete when you type it out in a field.
Alternatively, in custom code boxes (e.g. if you are needing to reference it in a javascript/3rd party tag box), you can use _satellite.getVar('shareType')

Big Commerce Custom Fields

I'm planning on allowing a client to provide a couple codes for each product that I'll need to reference with Javascript on the product pages.
Basically my plan was to use the Big Commerce's 'custom fields' to do so, but I'm having trouble spitting out the custom fields onto the product pages. I've been looking all over for some type of GLOBAL variable that allows me to reference custom fields, but I'm coming up dry. I would think there would be some type of GLOBAL array with all the custom fields in it, or a way to reference them by name directly.
Am I blind, or is there just no way to do this directly in the BC template file?
Thanks.
In Bigcommerce the custom fields can generally be found within the ProductOtherDetails.html Panel which contains a Snippet named ProductCustomFieldItem.html. This snippet has the markup for each custom field that the system outputs.
Inside of the ProductCustomFieldItem.html Snippet are the two codes you are looking for: %%GLOBAL_CustomFieldName%% and %%GLOBAL_CustomFieldValue%%.
I ran into this as well - given that it's quite a long time later, I'm supposing there's no better answer - a decent amount of searching turned up nothing useful as it seems all you can do is output the full set of custom fields as a set of divs.
So, I output them into a div which was hidden:
<div id="fpd-custom-fields" style="display:none;">
%%SNIPPET_ProductCustomFields%%
</div>
and then set up a javascript function to get the value based on the name:
function getCustomFieldValue(label)
{
var value = '';
$('#fpd-custom-fields div.Label').each(function()
{
if($(this).text().toLowerCase() == (label.toLowerCase() + ':'))
{
value = $('div.Value', $(this).parent()).text().trim();
}
});
return value;
}
Doesn't feel quite right as it's not a very clean solution, but was the best I could come up with unfortunately!

Functional document preparation for xcode

I have to prepare functional documentation for objective-c class methods like below example.
/*!
#function getEmployeeDetails
#abstract getEmployeeDetails
#discussion This function will fetch employee details based on employee id
#param strEmpId
employee unique id
#result an Array of Employee
*/
-(void)getEmployeeDetails :(nsstring *)strEmpId{
}
I referred to HeaderDoc User Guide in the below link and got idea how to prepare manually
Is there any short cut keys for functional documents?
You can use VVDocumenter :
Writing document is so important for developing, but it is really
painful with Xcode. Think about how much time you are wasting in
pressing '*' or '/', and typing the parameters again and again. Now,
you can find the method (or any code) you want to document to, and
type in ///, the document will be generated for you and all params and
return will be extracted into a Javadoc style, which is compatible
with appledoc, Doxygen and HeaderDoc. You can just fill the inline
placeholder tokens to finish your document.
After running the project with Xcode, in any project, you can generate the documentation by typing "///" (you can change this string in the settings) :

How to localize selectOptions on the visual force page

I am trying to localize selectOptions on the Visual Force page.
Here is the .class code snippet:
List<SelectOption> options = new List<SelectOption>();
List<MyOption__c> dropDownValues = [SELECT Id, Display_Label_Name__c FROM MyOption__c];
for (MyOption__c val : dropDownValues) {
// Display_Label_Name__c field is the label from *.labels that needs to be translated
options.add(new SelectOption(val.Id, val.Display_Label_Name__c));
}
Here is the .page code snippet:
<apex:selectList value="{!myVal}">
<apex:selectOptions value="{!options}"/>
</apex:selectList>
Right now the dropdown displays the Display_Label_Name__c verbose. I am trying to see how I can display the translated version from the .labels file. Is it possible? If not, what's the work around?
Thank you for your responses!
All localisation of page text can be done with Custom Labels.
Enable the translation workbench with the languages you require.
Create labels for all the localisible text on the page.
Replace the page text with the labels.
Add a translation for each label.
Change your profile langauge to test.
But for your case you pull the select option text from a custom object. If the values of the select list are not expected to change frequently, less than once a week or so, then I would change to using custom labels.
Otherwise, you lose the value of Salesforce automatic language selection and have to implement something yourself.
I would recommend extending the custom object MyOption__c to have columns for all the supported languages. You could use an if/else block or dynamic apex to select the select option text.
Sample using Dynamic Apex
string language = ParseForSupportedLangauges(UserInfo.getLanguage()); // includes __c
list<sobject> dropDownValues = Database.query('SELECT Id, '+language+' FROM MyOption__c');
for (sobject val : dropDownValues) {
options.add(new SelectOption(val.get('Id'), val.get(language)));
}
ParseForSupportedLangauges() would be a custom method that checks for supported languages and assigns the default when necessary.
EDIT
Turns out there is a solution: Don't look for something until you need it, right?
Introduced in Spring '12 is the ability dynamicaly select the label to display suing array syntax. Also, the ability to create visualforce components from the controller was added but using the array syntax would be sufficient for your problem. This method would allow you to select the labels you want by using the query results from MyOption__c.
Using a repeat in visualforce to loop over the query results
<apex:repeat value="{!displayResultsValues}" var="labelName">
<apex:outputText value="{!$Label[labelName]}"/>
</apex:repeat>
Here is a good article to show the usage and syntax.

Resources