I am looking for expert advice on how to best serve multiple sites with one Drupal instance (using Pressflow 6.x). Let's consider the company needing this is called "ABC Group of Companies" and it has 3 sister concerns. So, altogether there will be four sites:
www.abcgroup.com
www.company-a.com
www.company-b.com
www.company-c.com
Here are the things that are most interesting:
The users will be shared among all
the sites
Each site will "mostly" host their own content (say the welcome text on home page, or menu items - different for each site)
Some contents, will be shown in all of the sites (say, a company-wide notice....or an employee directory)
The theme for each site will be different
Now, I am thinking of having DNS entry so each of the domain point to the same Drupal installation and when Drupal gets bootstrapped, I would like to sniff into the $_SERVER array to know which site is being hit. I'd then like to load the theme accordingly, show the contents specific to that site, and also show the contents that are shared with all the sites.
To make this happen, so far I have created a node type called "Site" and have created four contents for each of the sites. Then for each other content type (say, Page) I have put a node reference to the "Site" content type with multiple value so when creating a new content, the administrator can specify in which site that content will be showed. However, after that I am stuck.
I have tried to understand Contexts, Spaces, PURL - but haven't figured them out fully yet and I believe I could use the community power to help me out. What do you think is the best approach to handle this scenario ?
It'd be greatly helpful if anybody can suggest a direction.
Regards,
Emran
The way you are suggesting is certainly a way that you could do it, but have you considered domain access? I have used it in the past and found it to be very useful. there is also quite a large collection of modules which work with it. Different themes, Options as to which nodes should appear on which sites and shared users are all features that it has.
Hope this helps!
http://drupal.org/project/domain
First up, I strongly second hookds suggestion of using Domain Access Module for this (+1). It has extensive support/features for your scenario and already covers most of the hard parts you'd need to solve yourself otherwise.
Second, if you insist on trying to do this yourself, I can assure you that it is possible, as we have done something pretty similar recently (some special requirements ruled out domain access), but it was a lot of work, especially when functionality provided by contributed modules would not fit well into our 'unusual' scenario.
Given the multitude of special cases you'd have to cover, it is hard to point out a general direction (apart from suggesting to use Domain Access Module ;) but one major point would be to check out the custom_url_rewrite_inbound()/custom_url_rewrite_outbound() function combo. These will allow you to do pretty low level URL manipulations for incoming requests, as well as for URLs generated for output, both of which you'll need to do if you you want to serve multiple domains from the same instance.
Did I mention that you should check out Domain Access Module before you try to build this yourself?
It sounds like there will be virtually no content shared between these sites. Will you be wanting a single login across all sites?
Remember, Domain Access uses 1 shared database.
You could also just do a regular multi-site install, and share certain tables.
I give Domain Access two thumbs up, but just make sure you really need what it actually does.
Also, I would look into the Feeds.module. You can pull content from anywhere (especially another drupal site) and it imports it directly and creates nodes and fields automatically from it.
Related
I am new at web development, and I have started to work on a small website just recently. Now the problem is, that since it is my first time, I move my pages a lot on the server, because of which I have to keep updating all the other pages that link to it. So, I was thinking of a dynamic way of linking the pages, so that I don't have to update at several places, but only at one.
How it is going to work is that,
there is going to be a separate database kind of thing that will contain all the webpages' updated address, and a unique key to identify them. eg. page12345 = "/about/us.php"
and anywhere where I want to include a link to the page, instead of typing .., I'll have to type something like .., or something like that
This method will also enable me to assign tags/categories to pages, and, or add other properties to them. And, I'll probably also use it for media files as well later.
Now, the thing is, I can think of only two ways to do so, one is using an array in PHP, and other is using MySQL database. The array will probably be too much to handle when the site grows and there are, like thousands of pages, on ther other hand, MySQL database will probably prove to be slower, and at the same time more of a hassle.
So what is it that you suggest? Which will be more efficient. Or is there a better way, I am open to any other ideas that you may have.
The typical way to manage that is to not worry about URLs manually at all and leave up to a router. In the end, URLs are just a technical implementation detail of the HTTP protocol. What you really want to do is identify specific pages/actions uniquely. Have a look at any reverse-routing capable router; here the Symfony implementation:
blog_show:
path: /blog/{slug}
defaults: { _controller: 'BlogController::showAction' }
Read this blog post.
This is admittedly a very high level abstraction, using YAML for specifying routes and Twig for templating with a custom defined function. However, it hopefully demonstrates the goal: don't worry about URLs much at all in your actual links. You need to have one canonical place where URLs are defined (the path in the above example), everywhere else you just refer to your target page by name (blog_show here). If you need to move URLs around, there's exactly one place where you need to do so. The thing in the middle that makes this work is the router.
I am currently trying to figure out a way to create templates for a number of pages that look exactly the same. The only thing that is different is the content part.
I have worked with PHP and include() to separate several parts of my pages, but still need something that allows me to set a default layout and styling of an entire page since I will be creating thousands of pages that are identical.
Please help me with some tips! Highly appreciated.
thousands of pages that are identical.
As stated in the comments, you should definitely go with a CMS (Content Management System)
Main features of a CMS:
Allow for a large number of people to share and contribute to stored data
Control access to data based on user role (i.e., define information users or user groups can view, edit, publish, etc.);
Facilitates storage and retrieval of data;
Control data validity and compliance;
Reduces duplicate inputs;
Simplify report writing;
Improve communication among users.
Define data as almost anything: documents, movies, texts, pictures, phone numbers, articles etc.
Content Management of Pages
Reference: http://en.wikipedia.org/wiki/Content_management_system
With that said, unless you want to spend countless hours studying and learning (which is not a bad thing) but it seems that you simply want to get this sophisticated website working, then a CMS is what you really need.
Take a look at what i believe are the top CMS's out there:
Joomla
Wordpress
Dupral
In a nutshell, you just need to get your Host, http://www.godaddy.com/ (not my personal favorite) but for simplicity; godaddy will install the CMS for you with a click of a button, it will setup everything and get you up and running! After that is complete, you can login via the administrator panel and play around with the settings to see how things work.
I would start with WordPress, heres a nice site to get you going once you have everything setup (assuming you go for Wordpress CMS)
http://www.siteground.com/tutorials/wordpress/wordpress_start.htm
http://codex.wordpress.org/Site_Design_and_Layout
Have fun! Hope this helps.
Is it possible(out of the box) to have multiple website running on one Joomla installation.
The idea is to give clients a unique domain(or sub domain) and based on the request coming from a particular domain the view should be assembled (theme selection, articles, pages)..
Is it possible.. ??
It important that for each domain we should have a unique theme.
I am not particular about Joomla..If the same is possible with ease in any other CMS like Drupal,etc then please share your thoughts about the same.
Thanks in advance
In Drupal this is called "multisites" and it's easy to have each site have its own theme and/or even have additional modules used only on some sites, but all sites generally using the same Drupal installation. Anyway, what you describe is commonly done in Drupal and not too hard to accomplish.
More info here: http://drupal.org/documentation/install/multi-site
i am not sure about installation, but you can store all the data into a single database, but keep in mind that it is possible with multiple prefixes,
means like you have two joomla sites one with 'jos_' prefix(by default joomla prefix, you can change this) and the other with different prefix
I am going to be making a series of about 5 sites. They need to all run on the same system. I am planning on making them all point to the same server, then depending on which domain is used to access it, different content/styles will be served. So its essentially going to be 5 or so different retail sites specializing in a particular product type.
But all using the same back-end code so that it is much easier to maintain. I have never set anything like this up before and want to know if there is any information I should consider or if anyone knows of a good place that explains how to do this well?
Also we are not hosting ourselves but going through a hosting company (if that matters).
Thanks!
Sounds pretty straight forward to me:
Just have a directory:
/var/www/siteLibraries/foo.php
Or other suitable directory. Then have
/var/www/site1/foo.php
/var/www/site2/foo.php
and setup the default class loading in PHP (http://uk.php.net/manual/en/language.oop5.autoload.php) so that when the specialist site instantiates a class ... it will search the site's local libraries (for specialist overrides) and then default to the shared libraries. You can also arrange content this way.
A brief explanation, but a rough overview of how I would tackle it if you don't need to worry about both sites sharing permissions (I assume clients wont edit code).
Remember: your per-site code should specialize from the default code base (OOP is great for this). What is not specific, is shared. Of course, the shared code-base should be aware it is shared, so things like logs should specify which specific site was utilizing the library when an error occurs and all that.
Good Luck
I'm currently in the process of writing a content management system that addresses this exact issue. A few things that I found helpful to think of.
When developing your sites, reduce them each to the lowest common denominator. That is, what elements are common to all of your websites? For example, each website will have a series of pages, and probably some form of shopping cart system.
For my system, I have a separate template file for each site. This way, I keep my PHP and HTML apart, which makes things a lot easier. Once I had the lowest common denominator, the hardest challenge for me was telling sites apart.
I used my htaccess file to redirect example.com to www.example.com - this way, I can then reliably pick up www.example.com from the header, and use that to select the information for a given site from the database.
Aiden also has some good points on code specific. For me, I found that code wasn't particularly the issue, but rather how I implemented that code for a multi site environment.
Hope this helps.
If you want your sites to have different code bases, Aiden's approach looks pretty good.
If your needs are simpler, i.e. all sites run the same code, but display different content based on the domain name, then you can also get away with a simpler solution.
Point all domains to the same directory where your scripts live, and differentiate what kind of content to send based on the HTTP "Host" value.
I.e.:
$host = $_SERVER["HTTP_HOST"];
$rs = mysql_query("SELECT * FROM products WHERE website = '$host'");
// ...etc
N.B: This code is for illustrative purposes. As written it is vulnerable to SQL injection, you should protect it appropriately.
I need to limit access of content on Drupal site based on the Drupal User's Role.
http://site.com/managers/intro
http://site.com/managers/reviews
http://site.com/managers/up-for-raises
The content can be of multiple content types and isn't limited to one specific content-type. These content types will be used elsewhere on the site so I can't lock down the whole content type.
I can get all the nodes/views to live at those addresses by menu settings when they are created, but I don't know how do I limit access via role other than a bunch of preprocess functions in template.php, but that seems to be the wrong way to do it.
I searched for a module and asked on #drupal-support IRC, but no results came up that use drupal roles as the limiting factor.
Although this is an old question, the Path Access module does exactly this now. Here is an excerpt from its project page:
... gives site administrators an additional layer of access control to all pages of a Drupal site.
Benefits: Although a lot of the Drupal modules provide some degree of access control permissions it never covers all possible requirements users have. Path_access provides the means to restrict pages based on their path alias - meaning you can lock out certain user role groups from whole sections of a site using wildcards.
Seems to me that if 'managers' is always going to be in the URL for that section, you could write a little tiny module that uses hook_init to basically say if the current user's role isn't one of these specified roles, and the url contains "/managers/", then drupal_goto() the login page.
You could also use the Rules module to get that done pretty easily, though if that's the only thing you'd be using Rules for, then it's not worth it.
There are also plenty of access-by-node modules (such as nodeaccess of all things), but these would also probably be more effort that it's worth to accomplish such a simple task.
If i got it right, what you are trying to achieve is to have only certain roles being able to access pages located at a given URL.
BY USING A CONTRIB ACCESS MODULE
As already mentioned by mcrittenden, there is a plethora of modules that allows you to tweak content access. Among them, content access can surely do what you want to, as it allows you to set up permission for each node separately.
BY USING FLAG + VIEWS
Another possible way to do this without coding, is with a combination of the flag module the views module. Here's a brief overview of how I would do:
Create three flags, which you can use to mark content (any type of content!) that will have to be viewed at any of the addresses you specified in your question (for example: create a flag "intro" that you will use to mark nodes that have to be displayed at the page "/mangers/intro")
Create 3 views (one for each address you listed in your question) that would pull out of the DB the nodes you need by filtering them on the basis of your flag.
Set the permission of these views according to the role.
BY WRITING A MODULE THAT CHECKS THE URI AND BLOCK UNAUTHORIZED USERS
You surely can do this. The main advantage would be that it would be a very lightweight solution in terms of CPU and memory load, but there are a few gotchas you have to pay attention to. For example the fact that you can always access your content via urls in the format the http://example.com/node/nodenumber), so you have to check a URL for its aliases too. But also the fact that a user might append a bogus ?something to the URL and you have to write the regex to take in account for such case...
(Also the idea of the rules module given by mcrittenden is a good one, but I did not mention it as I thought to it only when I read his answer).
Hope this helps!
You could also investigate Menu Access, which allows you to associate access between a role and a menu, or a role and a menu tree. (Keep in mind that in Drupal, the "menu router" table is mysteriously not just the UI, but also the traffic router which connects every piece of content to a URL.)
Because all items are associated with menu entries, you do not have the problem of the path alias not necessarily being universal. You can also use modules such as Menu Block to mimic book navigation.
This module appears to be closer to an Alpha or Beta release despite it's full & recommended status, so be careful on production sites.