I have table with categories and instead of having name column for every language, I'm storing translations so it looks like this:
1 2 category.macbook_12.name img-12 category.macbook_12.title category.macbook_12.title macbook-12.jpg 0
2 category.macbook.name macbook category.macbook.title category.macbook.description macbook.jpg 0
3 2 category.macbook_air.name macbook-air category.macbook_air.title category.macbook_air.description macbook-air.jpg 0
4 3 category.macbook_air_11.name macbook-air-11 category.macbook_air_11.title category.macbook_air_11.description macbook-air-11.jpg 0
5 3 category.macbook_air_13.name macbook-air-13 category.macbook_air_13.title category.macbook_air_13.description macbook-air-13.jpg 0
6 2 category.macbook_pro.name macbook-pro category.macbook_pro.title category.macbook_pro.description macbook-pro.jpg 0
7 6 category.macbook_pro_13.name macbook-pro-13 category.macbook_pro_13.title category.macbook_pro_13.description macbook-pro-13.jpg 0
....
I'm trying to create form with entity field. Like this:
->add('categories', EntityType::class, [
'class' => Category::class,
'choice_label' => 'name',
'placeholder' => 'form.product.category.placeholder'
])
It's not translating name categories but without translating them.
I think, I should customise entity_widget and add |trans to it, but I can't find original one so I can edit it, because I'm not sure how to fetch data from entity.
Where can I find original entity_widget?
Or is there another way to force translating?
Thanks
If you want to translate choices in your form, you can set
choice_translation_domain => 'messages'.
Your translations MUST be in directory
the app/Resources/translations directory;
the app/Resources/<bundle_name>/translations directory;
the Resources/translations/ directory inside of any bundle.
via Docs
and stored in file messages.{NEEDED_LANGUAGE}.yml as #DOZ said.
NEEDED_LANGUAGE can be short (en, de, ru, pl) or long (en_US, en_AU, en_GB).
Also you can name your translations as you want, but with NEEDED_LANGUAGE notation. So your category.yml file must be named category.en.yml and must stored in translations directory.
For using translations from your custom file, u must set translation_domain and choice_translation_domain manually on each field or in twig file globaly.
# src/{BUNDLE_NAME}/Resources/translations/messages.en.yml (based on symfony version)
category:
macbook_12.name: "Macbook 12"
macbook_12.title: "Macbook 12` laptop"
macbook.name: "Macbook"
macbook.title: "Macbook laptop"
form.product.category.placeholder: "Awesome macbooks here!"
# ... and yet
Related
I have a problem where I have a list of fields from a table (not static, can be modified by user), and I need to generate a report using these user selected fields. The report can show all the rows, no need for aggregation or filtering.
I thought I could create a report layout then using a filemaker script to populate it but can't seem to find the right commands, can someone let me know how I could achieve this?
I'm using filemaker pro 18 advanced
Thanks in advance!
EDIT: Since you want a dynamic report, then I recommend you look up a technique called "Virtual List" for rendering the data.
Here's an example script that iterates over a found set of records and builds the virtual list data in a variable (it doesn't show how to render it though):
# Field names and delimiter
Set Variable [ $delim ; Value: Char(9) // tab character ]
# Set these dynamically with a script parameter
Set Variable [ $fields ; Value: List ( "Contacts::nameFirst" ; "Contacts::nameCompany" ; "Contacts::nameLast" ) ]
Set Variable [ $fieldCount ; Value: ValueCount ( $fields ) ]
Go to Layout [ “Contacts” (Contacts) ; Animation: None ]
Show All Records
Go to Record/Request/Page [ First ]
# Loop over all the records and append a row in the $data variable for each
Set Variable [ $data ; Value: "" ]
Loop
# Get the delimited field values
Set Variable [ $i ; Value: 0 ]
Set Variable [ $row ; Value: "" ]
Loop
Exit Loop If [ Let ( $i = $i + 1 ; $i > $fieldCount ) ]
Set Variable [ $value ; Value: GetField ( GetValue ( $fields ; $i ) ) ]
Insert Calculated Result [ Target: $row ; If ( $i > 1 ; $delim ) & $value ]
End Loop
enter code here
# Append the new row of data to the list variable
Insert Calculated Result [ Target: $data ; If ( Get ( RecordNumber ) > 1 ; ¶ ) & $row ]
Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
# Save to a global variable to show in a virtual list layout
Set Variable [ $$DATA ; Value: $data ]
Exit Script [ Text Result: ]
please note this code is just one of many possible formats the virtual list can take. A lot of people, myself included, prefer to use JSON objects or arrays for each row of the list since it automatically handle field values with carriage returns. This is sort of the old-fashioned way. Kevin Frank at FileMaker Hacks has some good recent articles about virtual list techniques if you're interested.
PS, another great technique for rendering table data dynamically is to collect the data in a JSON array and render it in a webviewer with https://datatables.net/
I did something like this for the oncology department of UM om 1980 or so using 4th Dimension and a new plug in that used one line of code to create a web browser with all the functions that a doctor might want. The data was placed inside a variable as it was sent/returned and 4D could use a variable in the report to display the data.
FileMaker does not have this ability built in as 4D did so you will have to do it yourself.JSON is the most likely tool that I am familiar with. YouTube has many videos on JSON.
You have two classes of variables for your report: Column headers and column data to display. Fortunately Filemaker is quite good and very easy to design. Just make a typical report and replace the text/header or field names with a JSON variable or any. $ColumnName = JSON variable.
Create a JSON calculated field in the database. In that calculated field set the JSON variable and this can be used for all of the columns.
This is the essence of the idea with the final result to be determined by you. What you are asking for is not easy and would require serious work by a skilled JSON scripter.
On pay-per-view content nodes (with Drupal MoneySuite module) when I click 'override settings' to input an amount/ type for then node it crashes with this error, though I have tried many versions for the price (eg 1, or 1.00) and dates (eg 2, or 2 days). I have tried using full html, filtered html and plain text in the settings for the field. One answer on Stackexhange hints that this is a ut8 issue but I don't know what that means about how to solve it? Any tips?
The error is:
PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'full_html' for column 'protected_content_message_format' at row 1: INSERT INTO {ms_ppv_price} (vid, nid, price, expiration_string, allow_multiple, protected_content_message, protected_content_message_format, stock, out_of_stock_message) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => 96 [:db_insert_placeholder_1] => 96 [:db_insert_placeholder_2] => 3 [:db_insert_placeholder_3] => 3 days [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => This is a premium film- pay per view only. Get access [ms_ppv:price] to view for [ms_ppv:expirationLength] : [ms_ppv:addToCartLink] [ms_ppv:nodeTeaser] [:db_insert_placeholder_6] => full_html [:db_insert_placeholder_7] => 0 [:db_insert_placeholder_8] => ) in ms_ppv_insert_node_price() (line 774 of /home/cineafzh/public_html/sites/all/modules/moneysuite/ms_ppv/ms_ppv.module).
Looks like the MoneySuite module created the database table incorrectly.
Your error message explains exactly what's going wrong.
Column 'protected_content_message_format' is defined as a datetime column in your database. The value the module attempts to store in it is 'full_html', which is a string. It fails validation and throws an exception.
One workaround would be to edit your database and change the type of column for 'protected_content_message_format' to string, instead of datetime.
I can't guarantee that this won't introduce other undesirable behaviour without looking at the code, but it would definitely resolve this specific error.
I am having extreme difficulty making this doctrine2 extension works.
It is https://github.com/djlambert/doctrine2-spatial and theres not a lot of doc on how to create a polygon. I got the config file working and all but I am struggling with creating the actual polygon.
array:564 [
0 => array:2 [
0 => -73.698313
1 => 45.546876
]
1 => array:2 [
0 => -73.69813
1 => 45.546916
]
2 => array:2 [
0 => -73.697656
1 => 45.546899
]
3 => array:2 [
0 => -73.697413
1 => 45.546899
]
$poly = new Polygon($array);
[CrEOF\Spatial\Exception\InvalidValueException]
Invalid Polygon Point value of type "double"
This is the actual error Im getting. I tried creating points instead because apparently it doesn't like doubles.
$p = new Point($coord);
$temp[] = $p;
$poly = new Polygon($temp);
[CrEOF\Spatial\Exception\InvalidValueException]
Invalid Polygon LineString value of type "CrEOF\Spatial\PHP\Types\Geometry\Point"
After that, I was like ok, lets create a line string object and pass it.
$line = new LineString($points);
$poly - new Polygon($line);
[Symfony\Component\Debug\Exception\ContextErrorException]
Catchable Fatal Error: Argument 1 passed to CrEOF\Spatial\PHP\Types\AbstractPolygon::__construct() must be of the type array, object given, called in /Library/Web Server/Documents/mg/src/Momoa/ImmobilierBundle/Entity/geography/Quartier.php on line 131 and defined
Im just lost right now, the only thing I wanted was to store polygons in the database and call spatial functions such as CONTAINS. Do you have any recommendation or such other things to make all of this work.
After digging through the source code I found this validate function which seems to be the problem
case (is_array($point) && count($point) == 2 && is_numeric($point[0]) && is_numeric($point[1])):
return array_values($point);
break;
default:
throw InvalidValueException::invalidType($this, GeometryInterface::POINT, $point);
}
The way I'm understanding this is that the extension do not accept points that have decimal values ?! Huh, Does that mean I need to convert my coordinates to 2 integers ?!
I will post the solution I found. Basically you need to create your polygon like this
$line = new LineString($coords);
$poly = new Polygon(array($line));
//Or you can do it like this
$coords[0] = $coords;
$poly = new Polygon($coords);
//Following if you wanna use MBRContains or Contains
$dql = "SELECT p FROM polygon p WHERE MBRContains(p.geometry, GeomFromText('Point($lat $lng)'))=1";
//Dont use GeomFromText(:point), and then $point = new Point(array($lat,$lng));
Basically good luck guys, that library is useful but the documentation is BAD !
Spent the whole day on that yesterday !!
You can create it by passing data in constructor.
But the problem is that you should have a valid polygon data:
$p = new Polygon([[[lat1, lng1], [lat2, lng2], [lat3, lng3], [lat1, lng2]]]);
Be sure that in the Polygon
there are three arrays — array of lines, where line is an array of points, where every point is an array.
the path is closed — the last point equals to the first one.
The same truth for MultiPolygon but + one more array. F.e.
[[[["32.699005219026645","-117.18222600929262"],["32.694563070816095","-117.18437177650453"],["32.697687043641835","-117.17149717323305"],["32.699005219026645","-117.18222600929262"]]]]
I'm using WP-GeSHi in WordPress, and largely I'm very happy with it. There are, however, a few minor scenarios where the color highlighting is too aggressive when a keyword is:
a variable name (denoted by a leading #)
part of another word (e.g. IN in INSERTED)
the combination (part of a variable name, e.g. JOIN and IN in #JOINBING)
inside square brackets (e.g. [status])
Certain keywords are case sensitive, and others are not. The below screenshot sums up the various cases where this goes wrong:
Now, the code in GeSHi.php is pretty verbose, and I am by no means a PHP expert. I'm not afraid to get my hands a little dirty here, but I'm hoping someone else has made corrections to this code and can provide some pointers. I already implemented a workaround to prevent ##ROWCOUNT from being highlighted incorrectly, but this was easy, since ##ROWCOUNT is defined - I just shuffled the arrays around so that it was found before ROWCOUNT.
What I'd like is for GeSHi to completely ignore keywords that aren't whole words (whether they are prefixed by # or immediately surrounded by other letters/numbers). JOIN should be grey, but #JOIN and JOINS should not. I'd also like it to ignore keywords that are inside square brackets (after all, this is how we tell Management Studio to not color highlight it, and it's also how we tell the SQL engine to ignore reserved words, keywords, and invalid identifiers).
You can do this by adding a PARSER_CONTROL control to the end of the array:
'PARSER_CONTROL' => array(
'KEYWORDS' => array(
1 => array( // "1" maps to the main keywords near the start of the array
'DISALLOWED_BEFORE' => '(?![\(\w])',
'DISALLOWED_AFTER' => '(?![\(\w])'
),
5 => array( // "5" maps to the shorter keywords like "IN" that are further down
'DISALLOWED_BEFORE' => '(?![\(\w])',
'DISALLOWED_AFTER' => '(?![\(\w])'
),
)
)
Edit
I've modified your gist to move some of the keywords you added to SYMBOLS back to KEYWORDS (though in their own group and with your custom style), and I updated the PARSER_CONTROL array to match the new keyword array indexes and also to include the default regex that geshi generates. Here is the link:
https://gist.github.com/jamend/07e60bf0b9acdfdeee7a
According to me, what you are doing would take a lot of time. So, I suggest that you install a different plugin:
It has better features and supports more languages and in a better way. So, it would remove all these problems.
EDIT:
Hey, I tried out the same code with latest version and got following result-
EDIT:
So, if you don't want to use another plugin, then I'll tell you about the coding:
First open \wp-content\plugins\wp-geshi-highlight\geshi\geshi\tsql.php in your text editor.
Then, locate the array 'KEYWORDS' or search for it.
Add 6 to the last of it (after 5) and add your custom keywords in it. For example:
5 => array(
'ALL', 'AND', 'ANY', 'BETWEEN', 'CROSS', 'EXISTS', 'IN', 'JOIN', 'LIKE', 'NOT', 'NULL',
'OR', 'OUTER', 'SOME',
),
6 => array( //This line has been added by me
'status' //This line has been added by me
) //This line has been added by me
Note: I have just shown array element 5 (already present) and array element 6 (which I have made).
Then, to make it case-sensitive add below code to the last of 'CASE_SENSITIVE' array:
6 => true
The 'CASE_SENSITIVE' array should look like this:
'CASE_SENSITIVE' => array(
GESHI_COMMENTS => false,
1 => false,
2 => false,
3 => false,
4 => false,
5 => false,
6 => true //This line has been added by me
),
Now, you will have to add styling to the custom keywords. This can be achieved by adding below line to the 'KEYWORDS' element of 'STYLES' array. The starting of 'STYLES' array should look like this:
'STYLES' => array(
'KEYWORDS' => array(
1 => 'color: #0000FF;',
2 => 'color: #FF00FF;',
3 => 'color: #AF0000;',
4 => 'color: #AF0000;',
5 => 'color: #808080;',
6 => 'color: #0000FF;' //This line has been added by me
),
You can solve your problems by above guidelines, but for the part in which the plugin highlights incomplete words, I have found only one solution, that you update your plugin to latest version, because it solves this problem.
I have this array in a Drupal 7 installation, it outupts the term list that belongs to a specific vocabulary id:
<?php print render($content['taxonomy_vocabulary_3']); ?>
Now, what this does it outputs the result in a list, I would like to output it in a comma separated line.
Now, I suppose that I could do that with a foreach statement?
I´ve tried this, after reading the documentation, but it outputted nothing:
foreach($taxonomy_vocabulary_3 as $id=>$tag) {
echo "$tag, " ;
}
I´ve looked into what the Devel module told me about that array, and it showed me this:
taxonomy_vocabulary_3 (Array, 1 element)
und (Array, 2 elements)
0 (Array, 1 element)
tid (String, 3 characters ) 141
1 (Array, 1 element)
tid (String, 3 characters ) 320
But as you can see it shows the term id in each case, and not the term name...
What do you suggest? Thanks!!
You can load the term and then print it's title.
foreach($vocabulary as $tid) {
$term = taxonomy_term_load($tid);
// print whatever you want from this object.
print $term->title . ', ';
}
taxonomy_term_load
What you got is a build array - so that means that
$content['taxonomy_vocabulary_3']['#theme']
will be the theme function used to render the vocabulary. If you want to change the output you have two good solutions.
override the standard theme function in your theme - this will alter the output of all the calls to that theme function - in this case how all vocabularies is rendered.
Change the #theme value to a theme function of your liking - this could be a custom theme function you define in your theme.
For help on how to render the terms, you can take a look at how the original theme function is implemented - you can look it up at the Drupal API documentation.