4

Hope this is the right place for this question. I'm turning to you guys because I just cannot decide on the best way to go for this issue.

I'm currently developing a multi-language site which is split up in 2 main sections. Section A will be the main section and is available in 2 languages; Dutch and English. Section B will only be available in English.

Section B will have a different Menu, a slightly modified layout and some other blocks will be shown on different pages within the section.

I'd like to achieve the following url structure:

Section A:

/nl/title-of-a-node-in-dutch

/en/title-of-a-node-in-english

Section B:

/en/section-b/title-of-a-node-in-english (If possible, I'd like to drop the language prefix /en/ here)

I've configured Drupal with Entity Translation (+ Title module), so each node has translations on field-level and is not entirely duplicated like it would be the case with Content Translation (i18n).

The problem is that I'm going to have a lot of content (tens of thousands of nodes) for this site and some items should be shown in both Section A and B. Content that will be shared with both sections should only exist in one node. I definitely do not want to create an extra node with the same content just to make it available for Section B, this would be bad for content management and have a huge impact on the database.

Some of the solutions I've thought of:

  • Create 2 checkbox fields in the content type to indicate in which section the node should be made available. Create a hook on node insert/update and check which section was selected. If Section B was chosen, create an extra url alias which starts with /section-b/{node-title}. This would make the node content available via this extra alias, but I'm not sure what the implications this method will have, like how to handle breadcrumbs or (multilingual) Menu Structures for Section B

  • Configure Drupal to use a language fallback with Language Neutral and somehow add Section B as a custom language with the prefix 'section-b'. (is this even possible?)

  • Use url rewrites /section-b/my-title -> /en/my-title and programatically load the node and show the content via theming/templates

  • Maybe I can do something with Rules?

Relevant modules I'm using: pathauto, entity_translation, path_translation, i18n_translation, title

Do you guys have any other suggestions in how to set this up? I hope I'm clear on this issue. Content management is very important in this matter :)

Thnx!

2 Answers 2

0

I'm not sure if this article helps, but here it is: https://www.drupal.org/node/1516444

For something more complex, I've actually implemented a hook_url_inbound_alter() to control the redirection of pages and it's worked pretty well for me, but it involves creating the logic yourself. On the other hand, the benefit is that you can completely control when and where you redirect page visits.

0

You can look into pathauto.api.php located inside the pathauto module to see which hook suits you best for setting the path programmatically (if this is an option for you).

The path can be set or modified per language (which is german and english in this case) like this:

\Drupal::service('path.alias_storage')->save("/node/" . $node->id(), '/some_alias/' . $node->id(), "en");
\Drupal::service('path.alias_storage')->save("/node/" . $node->id(), '/some_alias/' . $node->id(), "de");

I hope I did get you right and this is useful to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.