I've created a multi-lingual website with Symfony2 using the (Gedmo) Translatable behavior extension for Doctrine2. This works fine but now i'm looking for a way to use the ElasticaBundle to create a nice searchoption. I want German users to search in the German-translation but also in the English translation.
At the moment i'm trying to use separate indexes for each language. My config.yml looks like this:
foq_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
articles_en:
client:default
types:
article:
mappings:
name: { boost: 5, analyzer: my_analyzer }
persistence:
driver: orm
model: Test\SiteBundle\Entity\Article
identifier: id
provider:
service: elastica.translation.provider.article.en
finder:
articles_de:
....
articles_nl:
.....
This works fine if you want to search through one index but searching two indexes seems not possible with this bundle or am I wrong?
Is there a way to do this? Any help will be appreciated!
Rick
You should probably just add one index for every article in every language and add a language to your index. You can then search your index for articles in one or more languages.
Related
I'm trying to figure out with Sylius routing, based on Symfony framework. I found that code
sylius_admin_channel:
resource: |
alias: sylius.channel
section: admin
templates: "#SyliusAdmin\\Crud"
except: ['show']
redirect: update
grid: sylius_admin_channel
permission: true
vars:
all:
subheader: sylius.ui.configure_channels_available_in_your_store
templates:
form: "#SyliusAdmin/Channel/_form.html.twig"
index:
icon: share alternate
type: sylius.resource
But I could not find any information what is it | for resource. Any help?
Thanks.
It's the YAML syntax for a multi-line string (that preserves newlines).
So sylius_admin_channel is a mapping that has two keys (resource and type) whose values are both string types.
It can be confusing to see in this instance because the string happens to also be valid YAML. I edited your question to include syntax highlighting for YAML which makes this a little more obvious, visually.
If I didn't know any better, I would have guessed that the | is there in error and resource should actually have a mapping type for its value. If you remove the |, then same symbols that were within that string still produce valid YAML for the whole file, but the value of resource would be a mapping, rather than a string.
Notice the difference in syntax highlighting, compared to the yaml in the question with the | removed:
sylius_admin_channel:
resource:
alias: sylius.channel
section: admin
templates: "#SyliusAdmin\\Crud"
except: ['show']
redirect: update
grid: sylius_admin_channel
permission: true
vars:
all:
subheader: sylius.ui.configure_channels_available_in_your_store
templates:
form: "#SyliusAdmin/Channel/_form.html.twig"
index:
icon: share alternate
type: sylius.resource
I have a symfony routing defined:
route_name:
path: /foo/{slug}-{jobId}
slug: can be bar-92-test-123
jobId: integer
What are the right regular expressions for slug and jobId for Symfony to handle the route correctly?
Normally the following regular expression can cover your need:
(.*)-(\d+)$
So it seems the last $ sign can solve your issue as well.
It works with the following requirements:
requirements:
slug: '([a-z0-9]+[-]?)+'
jobId: '\d+'
I read the Bundle documentation, but I can't find how to change these labels:
So, I found how to change the list.page_title, but I can't find about point 1, 2, 4, 5 on the image. Also, I can't find how to remove the ID column (field) from any list view. I follow the tutorial, but when he install Easy Admin Bundle action.search was Search for him, action.new was New etc...
I tried with:
list:
fields:
- '-id'
You have to enable symfony translation module in your config.yml:
framework:
translator: { fallbacks: ['%locale%'] }
I'm trying to add ability to sort products by price and date. Are there any predefined methods to do that, or the only way is to implement them by hand? From sylius.yml we're getting such strange route:
%sylius.model.taxon.class%:
field: permalink
prefix: /t
defaults:
controller: sylius.controller.product:indexByTaxonAction
sylius:
template: SyliusWebBundle:Frontend/Product:indexByTaxon.html.twig
Which can be used like {{ path(taxon) }}. But just adding sorting parameter doesn't work for me. Any ideas?
You need a version, which incorporates the Pull Request #2122. Either the latest master, or you fork the 0.11 branch and cherry pick this fix.
Then you can simply define in your config.yml to only override the required defaults:
sylius_core:
routing:
%sylius.model.taxon.class%:
defaults:
sylius:
sorting:
order: desc
Propel 1.6 and Symfony 1.4
I'm looking for a way to programmatically set the default propel connection for the length of an entire php process. The issue is that I'm using an alternative db for testing purposes and I have a good deal of code that doesn't pass the PropelPDO object currently.
Can this be done? Any tips? Thanks.
Why not use environments in your databases.yml?
dev:
propel:
class: sfPropelDatabase
param:
classname: DebugPDO
etc, etc
stage:
propel:
class: sfPropelDatabase
param:
classname: PropelPDO
etc, etc
prod:
propel:
class: sfPropelDatabase
param:
classname: PropelPDO
etc, etc
So, the solution to this was to use the following, pretty clean and sweet:
//override the "default" "propel" dsn and set it to our testing db!
\Propel::setConnection(
"propel",
Propel::getConnection(SqliteSetup::$databaseName)
);