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.

Category questions across multiple sites

July 21, 2010 7:13pm

Subscribe [3]
  • #1 / Jul 21, 2010 7:13pm

    coolstuffchannel

    114 posts

    I am trying to pull content from multiple sites using MSM, and here is what I’d like to do:

    I curently have approx. 7 sites all on MSM and if an article is written on one site, but possibly appropriate on more than one site, I’d like to be able to pull the first paragraph to the “other” sites, then link back to the original to read the article.

    All good here and I know how to do that.

    The code would look something like: site=“A,b,c,d” weblogs=“1,2,3,4” category=“140”

    However, does each site content need to be categories as Category 140?  In other words, if I am on site B for instance and want the homepage there to pull all content from site be, and any content from site A, category 140, Site B, category 150, how to I do that in a succinct fashion, if at all?

    What I am trying to avoid is having to go back into every article in every site and categorize all content as coming from that site.  Not sure if that makes sense or not…

    I am concerned is I use site=“A,b,c,d” weblogs=“1,2,3,4” category=“140”, I will only get content from category 140 and not all the content from site B in addition.  I also don’t want to have to have to have my code so long as it must list every category and every site, and every blog.  The code would be rather heavy and I have over 190 categories already…

  • #2 / Jul 22, 2010 12:36pm

    Design by Front

    106 posts

    Hey there,

    Have you tried simply piping the categories together?

    category="140|150"

    Category IDs are always unique (even across your MSM sites), so if you need to target specific categories in each site you will probably have to list them all out separated by pipes.

    If you have over 190 categories though, it may be faster to exclude the ones you dont want:

    category="not 140|150"

    Depending on how you’ve grouped your categories together, it might also be an option to use the “category_group” parameter instead of targeting single categories.

    Hope this helps,
    Chuck

  • #3 / Jul 22, 2010 12:43pm

    coolstuffchannel

    114 posts

    How does the category_group work?

  • #4 / Jul 22, 2010 12:49pm

    Design by Front

    106 posts

    In the EE control panel, if you go to:

    Admin  ›  Weblog Administration  ›  Category Groups

    You can see the ID for each Category Group on the left. By using the “category_group” parameter you can filter entries by all categories in that group instead of targeting each individual category.

    More info on the
    offical docs

  • #5 / Jul 22, 2010 12:49pm

    coolstuffchannel

    114 posts

    here’s another related question…

    With the above setup, I am pulling content in from several sites.  Rather than freak readers out by sending them to another site, I’d like to use a conditional.  SOmething of the sort of {if site =="site1}(then link via a pop-up, or at least extra text saying “from Site1”{/if}

    I’ve tried that however, and it didn’t work.  Any suggestions?

  • #6 / Jul 22, 2010 12:57pm

    coolstuffchannel

    114 posts

    Category groups looks like a good solution, however (and sorry to be a pest), if I choose a group from site 1, can I also just choose specific categories from site 2,3,4?

    In other words, would category_group=“12” category=“196” where the 196 is not part of category group 12 but in addition to that entire group.

    Put simply, can you work with groups and categories at the same time?

  • #7 / Jul 22, 2010 1:06pm

    Design by Front

    106 posts

    here’s another related question…

    With the above setup, I am pulling content in from several sites.  Rather than freak readers out by sending them to another site, I’d like to use a conditional.  SOmething of the sort of {if site =="site1}(then link via a pop-up, or at least extra text saying “from Site1”{/if}

    I’ve tried that however, and it didn’t work.  Any suggestions?

    We’ve hit this exact same issue recently :(

    The difficulty here is that the normal way to identify which site you are on is to use the {site_id} or {site_short_name} parameters. The problem is that these tags are global variables. So if you are currently on “Site A”, no matter where you put the {site_short_name} tag it will always return the short name for “Site A”, even if your currently pulling content from sites “B, C and D”.

    We didn’t come up with an easy way of doing this, we ended up looking at the weblog ID to figure out which site the information was coming from. Something like:

    {if weblog_id == 1}This came from Site A{if:elseif weblog_id == 2}This came from Site B{/if}

    Hopefully someone else has come up with a more graceful way of figuring out which site content is coming from, feels like it should be easier than this…

  • #8 / Jul 22, 2010 1:10pm

    coolstuffchannel

    114 posts

    Good solution, for me however, each site has approx. 50 blogs in it.  My code would be gigantic if I want to possibly include all 50 blogs per site, multiplied by 7 sites, all based on one category per site.

    I tried doing an if statement saying {if Category == 1} this came from site a {/if but that didn’t seem to work.

  • #9 / Jul 22, 2010 1:12pm

    Design by Front

    106 posts

    Category groups looks like a good solution, however (and sorry to be a pest), if I choose a group from site 1, can I also just choose specific categories from site 2,3,4?

    In other words, would category_group=“12” category=“196” where the 196 is not part of category group 12 but in addition to that entire group.

    Put simply, can you work with groups and categories at the same time?

    I would assume you can work with category groups and categories as long as the category belongs to that group.

    I suspect however, that if you try to specify a category group and a category which isn’t part of that group you may run into trouble. It’s not something I’ve tried to do before though, so it’s worth a shot 😊

  • #10 / Jul 22, 2010 1:18pm

    Design by Front

    106 posts

    Good solution, for me however, each site has approx. 50 blogs in it.  My code would be gigantic if I want to possibly include all 50 blogs per site, multiplied by 7 sites, all based on one category per site.

    I tried doing an if statement saying {if Category == 1} this came from site a {/if but that didn't seem to work.

    Remember to use the Category Variable Pair parameter, try:

    {categories}{if category_id == 1}Site A{/if}{/categories}

    Or in the case of Groups

    {categories}{if category_group == 1}Site A{/if}{/categories}
  • #11 / Jul 22, 2010 1:50pm

    coolstuffchannel

    114 posts

    That Worked!

  • #12 / Jul 22, 2010 1:57pm

    Design by Front

    106 posts

    Excellent! 😊

  • #13 / Jul 22, 2010 3:04pm

    Ingmar

    29245 posts

    Glad to see DBF was able to help (thanks!) 😊 please don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases