Jump to content

Multisite sharing template logic


Recommended Posts

Hi guys,

I have been playing around with multisite recently and wondered - what would be the best way to share some template logic between multisite instances?

I have an upcoming project where two different sites would have different users and setups etc but they need to share some basic similarities in look and functionality. I was thinking of setting up the sites as separate sites under multisite and then finding a way of sharing something such as a 'main.php' file that each template calls. I would also like to share a 'base.css' file between the sites as well. I want to do things this way because they want the potential to be able to expand into more sites over time - up to 5 or so.

What would be the best way of doing this?

Thanks in advance.

Link to comment
Share on other sites

You can use symlinks, but I also don't see any problem with just referencing the file you want directly. I'm not sure which multi site method you are using, but assuming you are using the built-in method with multiple site- directories. So if you want to include your /site-other/templates/home.php to include /site/templates/main.php, then you would just do this in your home.php:

include($config->paths->root . 'site/templates/main.php'); 

Likewise for your base.css file, except that you would use a URL instead:

<link rel='stylesheet' type='text/css' href='<?=$config->urls->root?>site/templates/styles/base.css' />
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...