Discussion:
Shared MultiSite Menus
Jesse Friedman
2013-05-30 15:16:04 UTC
Permalink
I have a rather unique situation. I have a multisite installation with
approx 600 sites.

Of these 600 sites, #500, #501, #502, and #503 need to share menu's with
each other.

Currently the best solution I have found is to use switch_to_blog() to pull
in the necessary nav menus, on each site. This works just fine, although I
can't really predict the load this might put on the network, as I know that
switch_to_blog() is not really the most efficient function.

So if you're on site #501 I'd use switch_to_blog 3 times to get the menus
from #500, #502, and #503.

All 4 sites use the same exact theme.

Option 2
I have also considered saving the menus as Site options in site #500. So
each time a menu is saved in #503, it will also save the raw HTML as a site
option in #500. This way, I only need to switch_to_blog() once, if I'm not
on site number #500.

Option 3
I have also considered saving the nav menus HTML as site options for all
sites, this way there will never be a switch_to_blog() function on site load

Of course, I will use transients to only run the switch_to_blog() once a
day.

Does anyone have any better ideas? I don't necessarily need code, but a
better plan of attack.
--
thanks

*jesse friedman*
jes.se.com *
*
Book: Web Designers Guide to WordPress -
http://wdgwp.com/onamazon<http://wdgwp.com/onamazon>
Twitter: @professor <http://twitter.com/professor>
Facebook: Like<https://www.facebook.com/pages/Jesse-Friedman/204793299545174>
Dobri
2013-05-30 15:29:11 UTC
Permalink
If it's this specialized, how about on menu save from any of the four sites you create a raw HTML flat file and dump it on the server? Then on render, just pull that file in. Doesn't really scale obviously but it works for a very specific case like yours, right?

~Dobri
Post by Jesse Friedman
I have a rather unique situation. I have a multisite installation with
approx 600 sites.
Of these 600 sites, #500, #501, #502, and #503 need to share menu's with
each other.
Currently the best solution I have found is to use switch_to_blog() to pull
in the necessary nav menus, on each site. This works just fine, although I
can't really predict the load this might put on the network, as I know that
switch_to_blog() is not really the most efficient function.
So if you're on site #501 I'd use switch_to_blog 3 times to get the menus
from #500, #502, and #503.
All 4 sites use the same exact theme.
Option 2
I have also considered saving the menus as Site options in site #500. So
each time a menu is saved in #503, it will also save the raw HTML as a site
option in #500. This way, I only need to switch_to_blog() once, if I'm not
on site number #500.
Option 3
I have also considered saving the nav menus HTML as site options for all
sites, this way there will never be a switch_to_blog() function on site load
Of course, I will use transients to only run the switch_to_blog() once a
day.
Does anyone have any better ideas? I don't necessarily need code, but a
better plan of attack.
--
thanks
*jesse friedman*
jes.se.com *
*
Book: Web Designers Guide to WordPress -
http://wdgwp.com/onamazon<http://wdgwp.com/onamazon>
Facebook: Like<https://www.facebook.com/pages/Jesse-Friedman/204793299545174>
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Otto
2013-05-30 15:43:52 UTC
Permalink
Post by Dobri
If it's this specialized, how about on menu save from any of the four sites you create a raw HTML flat file and dump it on the server? Then on render, just pull that file in. Doesn't really scale obviously but it works for a very specific case like yours, right?
Instead of a flat file, use a site-option.

http://codex.wordpress.org/Function_Reference/update_site_option
http://codex.wordpress.org/Function_Reference/get_site_option

-Otto
Jesse Friedman
2013-05-30 15:46:50 UTC
Permalink
Dobri, thank you and I considered that as well

Otto, I considered that as well, but... It seems strange having a site menu
for 1 client, in a global network wide site option. I can't think of a
reason why it would be bad, it just doesn't seem like a good practice.
Thoughts?

Jesse
Post by Dobri
Post by Dobri
If it's this specialized, how about on menu save from any of the four
sites you create a raw HTML flat file and dump it on the server? Then on
render, just pull that file in. Doesn't really scale obviously but it works
for a very specific case like yours, right?
Instead of a flat file, use a site-option.
http://codex.wordpress.org/Function_Reference/update_site_option
http://codex.wordpress.org/Function_Reference/get_site_option
-Otto
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
--
thanks
*
*
*jesse friedman*
jes.se.com *
*
Book: Web Designers Guide to WordPress -
http://wdgwp.com/onamazon<http://wdgwp.com/onamazon>
Twitter: @professor <http://twitter.com/professor>
Facebook: Like<https://www.facebook.com/pages/Jesse-Friedman/204793299545174>
Nicholas Ciske
2013-05-30 15:52:12 UTC
Permalink
Then use a transient in each site. Sure you're caching the same menu 3 times, but that keeps it encapsulated in that site and removes 99% of the performance issues (and the transient handles cache expiration).

_________________________
Nick Ciske
http://thoughtrefinery.com/
@nciske
Post by Jesse Friedman
Otto, I considered that as well, but... It seems strange having a site menu
for 1 client, in a global network wide site option. I can't think of a
reason why it would be bad, it just doesn't seem like a good practice.
Thoughts?
Jesse
Dobri
2013-05-30 15:50:48 UTC
Permalink
Otto's right, I forgot you could do site-wide options. That's probably the best place. Awkward, I know, but there's no harm in doing it.

Here's another idea: if it's just a shared menu(not 4 separate ones that you glue together) why not sync it up? Every time a menu is saved on one of the four sites, replicate the same menu on the other three. You'll only be doing this on menu save so it's not as heavy as doing it every page load.

~Dobri
Post by Otto
Post by Dobri
If it's this specialized, how about on menu save from any of the four sites you create a raw HTML flat file and dump it on the server? Then on render, just pull that file in. Doesn't really scale obviously but it works for a very specific case like yours, right?
Instead of a flat file, use a site-option.
http://codex.wordpress.org/Function_Reference/update_site_option
http://codex.wordpress.org/Function_Reference/get_site_option
-Otto
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Jerry Milo Johnson
2013-05-30 15:58:39 UTC
Permalink
can you add an action to the menu save, so that when you update the menu on
any of the 4 sites, you update the menu data for the others, too?

(so the switch_to_blog could happen in the admin, during save, and not on
the front-end during load)?
Post by Dobri
Otto's right, I forgot you could do site-wide options. That's probably the
best place. Awkward, I know, but there's no harm in doing it.
Here's another idea: if it's just a shared menu(not 4 separate ones that
you glue together) why not sync it up? Every time a menu is saved on one
of the four sites, replicate the same menu on the other three. You'll only
be doing this on menu save so it's not as heavy as doing it every page load.
~Dobri
Post by Otto
Post by Dobri
If it's this specialized, how about on menu save from any of the four
sites you create a raw HTML flat file and dump it on the server? Then on
render, just pull that file in. Doesn't really scale obviously but it works
for a very specific case like yours, right?
Post by Otto
Instead of a flat file, use a site-option.
http://codex.wordpress.org/Function_Reference/update_site_option
http://codex.wordpress.org/Function_Reference/get_site_option
-Otto
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Jesse Friedman
2013-05-30 16:02:07 UTC
Permalink
I think Otto's go it.

Dobri, thanks for confirming. It is 4 different menus that I'm piecing
together

Jerry, the issue with that is it will be dependent on the existence of 12
menus and that gets complicated.
Post by Dobri
Otto's right, I forgot you could do site-wide options. That's probably the
best place. Awkward, I know, but there's no harm in doing it.
Here's another idea: if it's just a shared menu(not 4 separate ones that
you glue together) why not sync it up? Every time a menu is saved on one
of the four sites, replicate the same menu on the other three. You'll only
be doing this on menu save so it's not as heavy as doing it every page load.
~Dobri
Post by Otto
Post by Dobri
If it's this specialized, how about on menu save from any of the four
sites you create a raw HTML flat file and dump it on the server? Then on
render, just pull that file in. Doesn't really scale obviously but it works
for a very specific case like yours, right?
Post by Otto
Instead of a flat file, use a site-option.
http://codex.wordpress.org/Function_Reference/update_site_option
http://codex.wordpress.org/Function_Reference/get_site_option
-Otto
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
--
thanks
*
*
*jesse friedman*
jes.se.com *
*
Book: Web Designers Guide to WordPress -
http://wdgwp.com/onamazon<http://wdgwp.com/onamazon>
Twitter: @professor <http://twitter.com/professor>
Facebook: Like<https://www.facebook.com/pages/Jesse-Friedman/204793299545174>
Loading...