Jump to content
apeisa

Multisite

Recommended Posts

This seems to be more tricky than I initially thought it would be. Will investigate this.

Share this post


Link to post
Share on other sites

Sounds like I'm going to need this module. But I have a few questions:

I'm a big fan of the XML sitemap plugin.. anyone have experiences using these two plugins together?

Are urls like http://domain/subdomain/article redirected to http://subdomain.domain/article 

if someone hovers the link does it show http://domain/subdomain/article ? or http://subdomain.domain/article ?

Share this post


Link to post
Share on other sites

From memory the XML sitemap class doesn't check for multisite needs, though I seem to recall someone asking this before and maybe even posting some altered code (I might have dreamed that bit thouugh!).

Share this post


Link to post
Share on other sites

Can I use and test out this module locally ie. using MAMP?

Some basic instructions would be great!

Also if I use it on a live host can I install processwire with the multisite module in a subfolder before I move it into the root?

Share this post


Link to post
Share on other sites

I don't use MAMP, but what you have to basicly is this:

1) Install ProcessWire with for example the domain maindomain.localhost which points to /Arjen/Sites/maindomain.com/.

2) Make sure it's working fine and install the Multisite plugin.

3) Create an entry in your virtual host file and point that domain to the domain in step 1. For example point seconddomain.localhost to /Arjen/Sites/maindomain.com/ as well.

4) Now both maindomain.localhost and seconddomain.localhost will load the same website.

5) Follow instructions above.

Share this post


Link to post
Share on other sites

I have pretty mixed feelings about this module myself. It does work (well, there is one user where it doesn't and I don't have a clue why), but all should be aware that there are many things to consider:

  • Complexity grows exponentially with each subsite you add. More templates, more fields, more pages
  • Your coding needs to be different if the site is subsite: $page->rootParent isn't actually rootParent, but the home. 
  • www.campaign-site.com/processwire/ admin isn't there, it is only at www.main-site.com/processwire/
  • Maybe not compatible with all the modules. Ie. form builder works, but you need to create new /form-builder/ page under each of your subsites.
  • Cross linking doesn't work yet. Ie. if you use get or find to find pages from other subsites, then echo $p->url() won't give the right url (this is should be actually easy fix, but not yet fixed)

If your subsite is big, I don't think using this module is good idea. For simple marketing campaign sites I think this is fine way to go, but for larger sites I would consider other approaches.

  • Like 2

Share this post


Link to post
Share on other sites

only the homepage of the subdomain works for me.

if I try go to:

subdomain.site.com/yadayada/

nothing happens. see:

corporate.ccw-global.com

www.ccw-global.com

Edit: I ended up moving the subdomain back to having it's own database. It might be more hassel to admin, but simpler to ensure good SEO with two different XML sitemaps. I had a few instances where /domain/subdomain/ due to the way pages were linked.

Anyways, I'll look forward to when this module gets beefed up, or when a next gen version gets released.

Share this post


Link to post
Share on other sites

I think we should consider a new module which covers some more functions. The concept of contexts in MODX for example is pretty straight forward (in theory). So I think something like this would be nice to have:

- define any desired rootParent as own context

- every context can have its own context settings (for example domain or even own alias with the same domain as the root, language, id of own 404 etc.)

- In your templates you could just refer to these settings via $context->my_setting

- the url creation has to be implemented with a hook (path::after?) so it works everywhere

- cross context linking should work (so TinyMCE has to tweaked I guess)

- fields, templates etc. can be shared between contexts (organisation via the new tag function)

- [...]

I think it is a very common use case to have several websites (domains) in one environment, so this would be awesome if we would have a module which considers all these "problems" and would work out of the box. So we could claim PW as "multi language, multi domain" without tweaking  ;)

Unfortunately this is beyond my PHP skills :-

  • Like 1

Share this post


Link to post
Share on other sites

The aims seem to be:

  • One site folder
  • One templates folder (which is where it gets messy)
  • One admin interface
  • Potential to share information across sites by calling something like $pages->context('sitename')->find('selector'); - This is the best way I can think of making it work anyway

I'm trying to do this without the time to draw a diagram, but the way I would see a new module working would be something like this:

  1. Have a single wire folder
  2. Have a /site/contexts/ folder, each site has its own folder within containing templates for that context (that way you could ignore the original templates folder)
  3. Write some API code to do something like $pages->context('sitename')->find('selector');
  4. DON'T show all the sites in one tree in the admin - no need, just have a drop-down at the top-right somewhere to switch between contexts
  5. Give them the option NOT to share the same database if desired. This then caters for marketing mini-sites to share the same DB but larger sites to be separate, as well as allowing for complete separation of templates and fields if desired (useful for creative studios with many sites)

This addresses all the requirements I think. There are a few compromises, but this ticks off the main aims I listed and doesn't over-complicate matters.

What do you guys think? MODx contexts made my brain hurt so I'm throwing this idea out as something that's hopefully simpler to setup, understand and manage :)

Other considerations are:

  1. You need some way of having single sign-on to switch between contexts (let's just call them sites hey? I'm getting confused every time I type that :D) if you use the separate databases approach
  2. Someone needs to add some functions into the API to make this work the way I described above, but I think that's possible :)
  3. Also the selectors could just be like $site->get('sitename')->pages->find('selector') but I like my first idea better :P Maybe $pages->site('sitename')->find('selector') though since I've totally gone off the term "contexts" now.
  4. Of course if you don't specify the site() part then it will default to the site that the template file is in.#
  5. And anything else you can think of...
  • Like 1

Share this post


Link to post
Share on other sites

Okay, haven't read the entire thread so I may have this completely upside down, but isn't it easier to have multiple Site folders with the first one as a default?

So, in each subsequent site it will use the templates in its own folder if they exists, if not it uses the templates from the default folder. Same for modules and admin template. There would have to be some exceptions, probably, so you didn't end up with the head from your own site1 folder and the footer from the default site folder, for instance.

But it might make deleting sites easier if it is just removing their entire site folder. Also means that they could be transferred to another installation, I would think ... somehow.

  • Like 2

Share this post


Link to post
Share on other sites

Keep the ideas coming, I like what I read ...  :)

I totally like the site/sites approach for the files with fallback to the original site folder. So one could share common templates and also create individual ones.

Share this post


Link to post
Share on other sites
That is the exactly same bug that I haven't been able to solve yet. I am pretty sure it has something to do with server settings. It modifies the url fine, but still loads the homepage only. Strange. Does anyone have any clue about this? Also notice this: http://corporate.ccw-global.com/it/doesnt/throw/404/

yeah, I noticed... well since I switched back to 2 databases, that link now throws a 301 to the root :)

Share this post


Link to post
Share on other sites

The sites I was thinking of using this multisite module has mainly product pages that need to be shared. So if someone updates a product PDF file it is reflected on both sites. These product pages will have body text, couple of tables of data text, images to download and PDF files. There are also other downloadable files in other areas of the site, employee contact lists and resources that would ideally be shared too.

What options do i have to share content like this if multisite is not suitable?

Share this post


Link to post
Share on other sites

Simplest would be to use Ryan's web service module. It is pretty straightforward and we are here to help with it.

  • Like 1

Share this post


Link to post
Share on other sites

I have one question about method #1; Is there an easy way to keep all of the backend translation in one place (wire folder?). I have multiple sites, installed as written in method 1, which have their own (json) language files for the backend translation but they seem to be saved seperate within each site-folder. In my case this isn't necessary so I'm curious in which file to change the location where the language variables are retrieved.

Share this post


Link to post
Share on other sites

The language translation files are considered part of the site's files rather than ProcessWire's core files, so they have to live in /site/assets/files/.../ rather than anywhere else. I suppose you could always make a symlink to set them up somewhere else. But I wouldn't bother with that unless it's creating an obstacle to have them the way they are. 

Share this post


Link to post
Share on other sites

Hi Ryan, well in this scenario (multiple sites with the same backend), it's more convenient to have them stored and maintained in one place so when we add some 'core functionality' which should be available for all sites, it would be more time consuming to update all of the different language-folders instead of just one. But I'll look into a way to use the symlink-option, thanks ;)

  • Like 1

Share this post


Link to post
Share on other sites

I would like to use this module but my PW installation produces the same error which Arjen described on the first page:

I can reach the page using the following URL:

http://www.maindomain.com/www.seconddomain.com/testpage/
But I can't reach the page using this URL:

http://www.seconddomain.com/testpage/

I followed the step by step explanation he described but still have no success getting the module to work.

If I open subdomain1.domain.com it redirects to the correct path of the tree and renders the menu as it should. The menu contains links like subdomain1.domain.com/festival, which seems correct to me. But all those links lead to the home page of the current subdomain, so in this case subdomain1.domain.com.

I read the whole thread and learned that this module is far from perfect but I need a way to manage four subdomains which use nearly the same templates from one PW installation. There is no other convenient way except for this module, right?

Share this post


Link to post
Share on other sites

I'm not really sure why it might not be working in your case, but it definitely doesn't sound right. It reminds me a bit of what one sees if they are trying to run ProcessWire without an htaccess file. What version of ProcessWire? Also, double check that those links have a trailing slash in them. The one you mentioned did not have a trailing slash, and I suspect that this module would require them. 

Share this post


Link to post
Share on other sites

Hi Ryan,

the links added to the module settings do not have a trailing slash. However, if i add one the module stops working since it fails to match the entry to the appropriate page on the second level.

I do have a .htaccess file but I am currently running the page in a local environment via MAMP. I am using the current ProcessWire Version 2.3.0.

I don't know why this should be an issue, but I will perhaps try to run it on my web hosting to make sure it does not have a problem with running local.

Share this post


Link to post
Share on other sites

Ezeey, I experiencing the same behaviour as my previous post. Did you manage to get it up and running?

Could it be that a previous fix has been reversed? It doesn't seem so though when looking at the github history.

Share this post


Link to post
Share on other sites

Unfortunately I didn't. As I thought I am having the same issues no matter if the page is running local or on my remote server.

Share this post


Link to post
Share on other sites

I got it working, but it is very hackish and definately should be looked after. I will fork apeisa's code tomorrow and try to figure out why my current version does work and the latest on github won't. For now you can check if this gist works for you. It does for me. It's an old version of the module I installed on my local machine at home. Then I changed some code with the new version. I didn't fix one warning, just placed an @ before it to stop the warning.

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild.  
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Steps (Read more) Manual override of the selected value (will still adhere to the rules above) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant If it's usable for others I'll add it to the Modules list  
      Changelog
      v002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional 
      v001
      - Initial release
       
      Thanks!
       
       
    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
    • By adrian
      This module allows you to automatically rename file (including image) uploads according to a configurable format
      This module lets you define as many rules as you need to determine how uploaded files will be named and you can have different rules for different pages, templates, fields, and file extensions, or one rule for all uploads. Renaming works for files uploaded via the admin interface and also via the API, including images added from remote URLs.   Github: https://github.com/adrianbj/CustomUploadNames
      Modules Directory: http://modules.processwire.com/modules/process-custom-upload-names/
      Renaming Rules
      The module config allows you to set an unlimited number of Rename Rules. You can define rules to specific fields, templates, pages, and file extensions. If a rule option is left blank, the rule with be applied to all fields/templates/pages/extensions. Leave Filename Format blank to prevent renaming for a specific field/template/page combo, overriding a more general rule. Rules are processed in order, so put more specific rules before more general ones. You can drag to change the order of rules as needed. The following variables can be used in the filename format: $page, $template, $field, and $file. For some of these (eg. $field->description), if they haven't been filled out and saved prior to uploading the image, renaming won't occur on upload, but will happen on page save (could be an issue if image has already been inserted into RTE/HTML field before page save). Some examples: $page->title mysite-{$template->name}-images $field->label $file->description {$page->name}-{$file->filesize}-kb prefix-[Y-m-d_H-i-s]-suffix (anything inside square brackets is is considered to be a PHP date format for the current date/time) randstring[n] (where n is the number of characters you want in the string) ### (custom number mask, eg. 001 if more than one image with same name on a page. This is an enhanced version of the automatic addition of numbers if required) If 'Rename on Save' is checked files will be renamed again each time a page is saved (admin or front-end via API). WARNING: this setting will break any direct links to the old filename, which is particularly relevant for images inserted into RTE/HTML fields. The Filename Format can be defined using plain text and PW $page variable, for example: mysite-{$page->path} You can preserve the uploaded filename for certain rules. This will allow you to set a general renaming rule for your entire site, but then add a rule for a specific page/template/field that does not rename the uploaded file. Just simply build the rule, but leave the Filename Format field empty. You can specify an optional character limit (to nearest whole word) for the length of the filename - useful if you are using $page->path, $path->name etc and have very long page names - eg. news articles, publication titles etc. NOTE - if you are using ProcessWire's webp features, be sure to use the useSrcExt because if you have jpg and png files on the same page and your rename rules result in the same name, you need to maintain the src extension so they are kept as separate files.
      $config->webpOptions = array(     'useSrcExt' => false, // Use source file extension in webp filename? (file.jpg.webp rather than file.webp) ); Acknowledgments
      The module config settings make use of code from Pete's EmailToPage module and the renaming function is based on this code from Ryan: http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/?p=32623 (also see this post for his thoughts on file renaming and why it is the lazy way out - worth a read before deciding to use this module). 
       
       
      NOTE:
      This should not be needed on most sites, but I work with lots of sites that host PDFs and photos/vectors that are available for download and I have always renamed the files on upload because clients will often upload files with horrible meaningless filenames like:
      Final ReportV6 web version for John Feb 23.PDF

×
×
  • Create New...