Jump to content


Photo

Multisite sharing template logic

templates multisite

  • Please log in to reply
4 replies to this topic

#1 raydale

raydale

    Distinguished Member

  • Members
  • PipPipPipPip
  • 100 posts
  • 46

Posted 23 May 2012 - 03:51 AM

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.

#2 Soma

Soma

    Hero Member

  • Moderators
  • 3,194 posts
  • 1749

  • LocationSH, Switzerland

Posted 23 May 2012 - 03:53 AM

If you can I would use symlinks to have one set of templates and link folder or single files to the local site.

@somartist | modules created | support me, flattr my work flattr.com


#3 raydale

raydale

    Distinguished Member

  • Members
  • PipPipPipPip
  • 100 posts
  • 46

Posted 23 May 2012 - 08:59 AM

Thanks Soma - I must admit I hadn't thought of that approach, not having dealt with symlinks much before.

Are there any potential performance issues to watch out for with using symlinks?

#4 ryan

ryan

    Hero Member

  • Administrators
  • 5,773 posts
  • 3120

  • LocationAtlanta, GA

Posted 24 May 2012 - 10:13 AM

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' />


#5 raydale

raydale

    Distinguished Member

  • Members
  • PipPipPipPip
  • 100 posts
  • 46

Posted 25 May 2012 - 02:37 PM

Thanks for the useful examples Ryan. That's definitely the preferred route for me.

I am most likely to be using the built in multi site method you refer to, yes.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users