5

I'm building a set of sites with MSM and intend to use a "parent" site for the organization to publish most of the common content that will be used for each of the "child" sites. Think of a restaurant with many locations where you want the location-specific information to be embedded into the page content for that location's site, yet the common information is pulled from the parent site.

For a simple example, if you're on a menu page for location A you'll see that location's prices, which may be different from the other locations. Assuming the menu is the same across all of the restaurants, I'd like to use the parent site to create channel entries for each entree and add in all of the common content there, yet have the location-specific price show on each location's menu page.

One simple option would be to create an entry on the child site and add fields for any of the location-specific content items. Then pass those items to the parent site template via embed parameters.

Child:

<ul>
{exp:channel:entries channel="entrees"}
   {embed="parent:menu/entrees" url_title="{url_title}" price="{price}"}
{/exp:channel:entries}
</ul>

Parent:

{exp:channel:entries channel="entrees" site="parent" dynamic="no" url_title="{embed:url_title}"}
   <li>
    <h2>{title}</h2>
      <div class="content">
        <img src="{entree_picture}" alt="{title}" />
            {entree_description}
         <span class="price">${embed:price}</span>
      </div>
   </li>
{/exp:channel:entries}

The drawback here is that each entry would need to be added on each child site, which doesn't scale well. In addition, the relationship between child site & parent site would be dependent upon the url_title being identical, which is error prone.

Any other options?

  • Did any of the answers help you? If yes, please mark the answer correct by clicking on the checkmark to the left of the answer. – Anna_MediaGirl Dec 22 '12 at 6:27
6

I would probably use a matrix in the main sites entry with two columns: location and price. One is location and one is price. Fill that in for each location. The location column would need to be a dropdown that the user selects the correct location. The dropdown would be set up so that the value is equal to the site name and the label to the Restaurant name.

In your template you would then do something like this.

{price-matrix search:location="={site_short_name}"}
    <span class="price">${price}</span>
{/price-matrix}

No embedded templates slowing your site down and more intuitive.

| improve this answer | |
  • Nice! We posted essentially the same answer at the same time, one with standard fields, one with Matrix. – Derek Hogue Nov 21 '12 at 22:12
  • Matrix is more flexible since you won't need to create a new field should they expand locations. But yes, very cool that we were posting at the same time. – CreateSean Nov 21 '12 at 22:14
6

What if you created fields for each location's price for that menu item. Then the field name would be prefixed with the child site's short_name.

  • atlanta_item_price
  • chicago_item_price
  • seattle_item_price

Etc.

Then in your child site template, you could use:

Price: {{site_short_name}_item_price}

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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