Symfony2 - APYDataGridBundle - Translate title in Entity annotations - symfony

can someone give me a hint about how to set the translated title in the annotations used by the APYDataGridBundle. I have already taken a look at the documentation but the 3 lines of explanation doesn't really explain to me what I need to do to achieve the desired result.

Not as well documented as it could be, but a quick look at the twig template code, lines 68-81, reveals the exact methodology: Your translation variable is the prefixTitle of your grid object (if defined, default value is an empty string) concatenated with your specified title for the column in the annotation, so [prefixTitle][columnTitle]
You are also free to add a second translation variable called [prefixTitle][columnTitle]_abbr that just gets used in the table header, but for example in the search menu the non-abbreviated version (without _abbr suffix) gets used. This is optional.

Related

Shopware 5 - Column name not changing via snippet

I have created a Free text field in s_articles_attributes table and also marked it as translatable, when i am viewing items > overview and enabling that column, the column name isn't changed to what i put in snippet.
Does anybody know how can i make it translate according to my snippet. I thought it should be straightforward. or is there something extra i should be doing?
The snippets for attributes need to follow a special scheme.
First of all the snippet itself needs to be in the namespace backend/attribute_columns
Then the naming of the snippet key is important:
for labels: <attbribute_table>_<attribute_name>_label
for support texts: <attbribute_table>_<attribute_name>_supportText
for help texts: <attbribute_table>_<attribute_name>_helpText
So for your case the snippet key has to look like this: s_articles_attributes_warehouse_us_label. Also don't forget to create it in the right namespace.
You can find more about this in our documentation: https://developers.shopware.com/developers-guide/attribute-system/#attribute-label-translations

How do I make a node title translatable?

I'd like to translate each node title as a string (using i18n). I'm trying this function in my theme template:
function theme_process_page(&$variables) {
$variables['title'] = t($variables['title']);
}
Yet when I refresh strings, none of my node titles are on the list. Is there something I'm missing?
And to clarify the function name is using my theme name, not the word "theme".
Title is my usual solution for this (I use Entity Translation, it works fine with Title module).
This module replaces node titles by a regular translatable text field. You can choose wich content type titles must be replaced (on the "Manage Field" forms, you'll find a "replace" link in the title row). Pretty useful.
Good luck
You should never use t() to translate user-supplied or variable strings. See the documentation on the function.
That said, there are some solutions, one is to use the built-in language support for entity fields. Following that you should be able to do something like this in a field hook (in a module, not in your template):
$langcode = $field_info['translatable'] ? $content_langcode : LANGUAGE_NONE;
$entity->{$field_name}[$langcode][0]['value'] = t("Salut!");

How can I always force most recent articles with the exact phrase using Drupal Apache Solr?

I want to find exact phrase results looking anywhere in the body or the title. It has to be ordered from the most recent to oldest. The only way I get pretty close results is by forcing quotes around all my searches via this hook:
/**
* Implements hook_apachesolr_query().
*/
function hcp_node_apachesolr_query_prepare($query) {
// Adding quotes to all searches so it gives an accurate search result
$search_result = $query->getParam('q');
$has_quotes = preg_match('/^(["\']).*\1$/m', $search_result);
if(!$has_quotes) {
$query->replaceParam('q', '"' . $search_result . '"');
}
}
My Bias Settings:
Results Biasing: All are set to ignore but More recently created is set to 10
Type Biasing: All set to ignore
Field Biasing: All set to omit.
This seems to work well with two or three word phrase but if for example I search a whole title of an article it can't find anything.
I tried setting the Title and The full, rendered content field bias to the same thing (21). Again it would show good results but it wouldn't be in most recent order(I think this was pretty close but just wish it displayed most recent first).
I also tried updating my schema.xml: updated WhitespaceTokenizerFactory to KeywordTokenizerFactory but I didn't get good results.
This is how I fixed this:
Installed Apache Solr Term Proximity Module Updated field bias to .3
for both Title and the full rendered content (the rest are set to
omit) Set the term proximity to .1
Set the Most recent created to 10
FYI I tried different settings and this seems like the best.

TAL Condition in Plone to hide HTML if it's a Document (Page)

I'm trying to modify my /portal_view_customizations/zope.interface.interface-plone.belowcontenttitle.documentbyline template with a tal expression, so that the document's author and the modification date do not show if the current portal type is a Document (Page). I don't mind if it shows for News Items, which are time sensitive, but not the Documents/Pages.
This is my failing Plone TAL expression:
<div class="documentByLine"
id="plone-document-byline"
i18n:domain="plone"
tal:condition="view/show and not:python:here.portal_type == 'Document'">
...
I've also tried:
<div class="documentByLine"
id="plone-document-byline"
i18n:domain="plone"
tal:condition="view/show and not:context/portal_type='Document'">
but still no luck. The tracebacks are pretty cryptic and don't relate to the TAL expression. However, if I get rid of my condition for portal_type, then it works again. Any thoughts are appreciated. A manual would be good, but I've looked at the official ones, and they don't mention this.
TAL's underlying TALES, the expression-engine of which TAL makes use of, doesn't support the mixing of expression-types in one expression. It's syntax allows only one expression-type to be specified (defaults to 'path', if omitted, btw), as no delimiter is provided (like a semicolon for chaining several TAL-statements in one element, e.g.).
But instead of mixing three expression-types you can use one python-expression, try:
python: view.show and context.portal_type()!='Document'
Update:
If you have customized a Plone's default-template via portal_view_customizations ('TTW'), now restricted python-methods cannot be accessed, that' why view/show throws an error.
It returns the allowAnonymousViewAbout-property of the site-properties, you can also check this condition yourself and your expression looks like:
tal:define="name user/getUserName"
tal:condition="python:test(name!='Anonymous User') and context.portal_type()!='Document';
Quick'n'dirty alternative:
Do it with CSS:
body.userrole-anonymous .documentByLine {display:none}
body:not(.template-document_view) .documentByLine {display:block}
This will render the hidden elements, but it's helpful for prototyping and such, or 'quickfixes' (no admin available, etc.).

Checboxes input helper PodsCms

i created a multiple checkboxes input helper adapting the code from this http://podscms.org/packages/checkboxradiobutton-yourvalues/
I modified it so that people don't have to hardcode values into the helper; instead values are taken from the column comment field (having a data field for columns would be appreciated in pods 2.0!)
Here is the helper: http://pastebin.com/w0UxDmnG
I encountered two problems, the first of which i already solved:
At thw beginning i enclosed the whole code in a function, to keep clean the namespace (isn'i it the right thing to do?). but i noticed that i do this, when i have two columns with this helper many strange things happen: the second column is blank, doesn't show checkboxes. After the second column with this helper no more columns are shown.Rich editor commands on all textareas don't appear and textareas themselves are non editable.
I suppose is an effect wrapping the code in a function. Unwrapped the code, problems are gone! (i wrote this because it can be helpful to developers out there.
I wanted to add a "Other" text field for comments outside the choices displayed with checboxes (like in google forms, for example). To trigger this "other" ("Altro" in the package i shared), pod creators have to write [] in the comments (eg: foo, bar, cat, []).
I was able to make the input, but, once data is filled in and the pods is saved, the data in the text field get lost. I really have no idea on how to fix this!
I hope my experience, and this helper could help someone, and i hope some could help me to improve it!
(and please someone create a podscms tag!!)
Pods 2.0 solves this kind of issue, it's now built into core as a field type option. Enjoy!

Resources