Access common resources from two contexts

I have two contexts - one for domain1. com and one for domain2. de (using ContextRouter). Both use the same elements - only some of the content and the page logo, … are different. BUT: multiple pages have the same content. Therefore I would like to maintain the content of those pages only once in context #1. Is this possible while maintaining the page logo, name, … from domain1. com if the page is accessed from domain1. com and the page logo, name, … from domain2. de if the page is accessed from domain2. de.

Currently, I am using [[~[[+id]]]] to access those shared pages - but this brings the user from domain2. de to domain1. com - including the different logo, … .

Maybe you can use a Symlink for this:

Welcome to the MODX Community @hal10000!

Here is how I handled it in a similar situation. I’ll use page_logo based upon your inquiry.

For each Context, I add a new Context Setting called page_logo and fill out the value accordingly.

Then I created a snippet called display_custom_context and call it as such:


context_name is important and the value for it is whatever context_setting name you added to each context.

In the example, I set a value in each Context for the page_logo Context Setting. Wherever, I call the snippet with the context_name being page_logo, the value for page_logo is echoed out.

In my snippet, the PHP is as follows:

if ( ! empty ( $context_name ) ) {
    $custom_context = $modx->context->getOption($context_name, null, 'default');
    echo $custom_context;

The display_custom_context is re-usable and can be called multiple times on a Resource or Chunk. The main thing is targeting the Context Setting you want to display.

Let me know if this helps.