ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Sharing category groups on different sites with MSM

October 21, 2008 5:06am

Subscribe [3]
  • #1 / Oct 21, 2008 5:06am

    bsjosten

    100 posts

    Hi,

    I am running a few sites under MSM.

    One of the sites will be pulling entries from all the other sites, and display them according to categories.

    Is there any way to share category groups between sites? I want the same categories (and category ids) on all sites, if possible. Maybe with an SQL hack?

    Thanks,

    /Bo

  • #2 / Oct 21, 2008 10:20am

    Robin Sowell

    13255 posts

    Stock, you can’t do it.  A hack, I am really not sure.  The categories are tied to sites as well, and I suspect that might be the trouble with trying to associate them with a weblog in a different site manually.  I think this is more a case for a feature request, as it would likely go beyond a simple tweak.  Haven’t tried it, so I can’t swear.  But I wouldn’t promise a client I could do it- because it’s complex enough there could be lurking issues.

    Make sense?

  • #3 / Oct 21, 2008 10:30am

    bsjosten

    100 posts

    Robin,

    The client is myself… so no problem with promises 😊

    It seems to me that the category_ids just get assigned sequentially, so can I assume there won’t be any duplicates between sites?

    The hack I had in mind was to somehow assign the same category group id to several sites. It seems to me it could be done. Could you be so kind to ask around if this is a safe thing to do with an SQL editor? I promise I won’t tell anyone else 😉

    Thanks,

    /Bo

  • #4 / Oct 21, 2008 10:36am

    Robin Sowell

    13255 posts

    Right- you won’t get duplicate ids between sites- even if you copy an existing category when you create the site.  Well- if you import the site, the ids don’t change- but the site_id associated with them flips.  As to safe, it’s not really safe to dink with the database directly.  But as long as you have a backup and are comfortable rolling back?  It’s no big deal.  If you hose something, just roll it back. 

    The problem you’re likely to run into- check out exp_categories- there’s a site_id field in there.  So they can only be assigned to one site.  That’s going to be the glitch.  Make sense?

  • #5 / Oct 21, 2008 10:45am

    bsjosten

    100 posts

    Thanks Robin,

    Well, maybe this is not such a great idea after all.

    Another option I can think of is a custom weblog field, identical for all sites and weblogs, with “custom” categories, such as A, B, or AB. Or will this be a performance hit compared to using categories, since I cannot use this directly in the exp:weblog:entries expression? I would have to check for it with a string compare inside the weblog:entries loop.

    /Bo

  • #6 / Oct 21, 2008 11:07am

    Robin Sowell

    13255 posts

    Hm- like a dropdown?  And maybe use the search parameter and pass it dynamically?

    It would take a performance hit.  And I won’t swear it will work- because while the field names will be the same across sites, the field ids won’t.

    Wonder if one of the tag modules would be an option?  But I’m not sure how they play across MSM sites either.

  • #7 / Oct 21, 2008 11:35am

    bsjosten

    100 posts

    Robin,

    Could you find out if the search:fieldname would work across sites? That would save me some time.

    I will investigate the tag option, although I would like to avoid mixing these categories with my “real” tags - a lot of extra code would have to be written to exclude them from tag clouds and the like.

    Thanks,

    /Bo

  • #8 / Oct 21, 2008 12:10pm

    Robin Sowell

    13255 posts

    Ah- no, doesn’t look like it will search the subsite.  I am not thinking of a brilliant way to do this.  I can’t even swear tags will work, as I’ve never tried across MSM- though I did see Solspace’s latest update added MSM capability.

    Maybe some php to ‘map’ categories in one site to their counterparts in another.  Then instead of EE behaving normally on a category page, you grab the cat in the url, map it to its counterparts, and echo the resulting pipe delimited string as the category parameter?

    Clunky but that might work.  Could do the mapping dynamically, but you’d be adding some overhead.

    Thoughts?  And I may shift to ‘How to’ since we’re moving into brainstorm territory.

  • #9 / Oct 21, 2008 2:52pm

    bsjosten

    100 posts

    Robin,

    Thanks for the footwork. And please move this thread to “How-to”.

    Grabbing the category out of the url doesn’t work, since it is not always there. The home page is one example where I need to consolidate news of a particular “type” from several sites.

    But there has to be a way. We just haven’t thought of it yet. Shared category groups between sites seems to be the most promising avenue, but also somewhat scary, since several of the sites are live and any SQL-hacking could have dire consequences.

    Let’s hope for good luck in the “How-to” forum!

    /Bo

  • #10 / Oct 21, 2008 4:27pm

    Ingmar

    29245 posts

    Moved as per request.

  • #11 / Nov 08, 2008 4:45am

    bsjosten

    100 posts

    Hi,

    I had previously given up on using categories, because an earlier reply in this thread indicated that site_ids where somehow added to categories, and that it wouldn’t work with MSM.

    However, some additional testing seems to indicate that category ids are unique AND can be used across sites. Am I wrong? Is this just a coincidence, or can I safely use category ids across sites after all?

    Thanks,

    /Bo

  • #12 / Jul 01, 2014 1:51pm

    David Hyland

    211 posts

    I know that this thread is now 5 years old but is it still the case that categories cannot be shared across sites? Is there now a cunning way to do this via an addon or some other config change?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases