Jump to content
apeisa

Multisite

Recommended Posts

Thanks for your reply, Soma. And also thank you for developing the fantastic Multisite module!

To further test this, I set up a clean installation of ProcessWire 3.0.30, activated link abstraction and put some internal links into the body-fields. Then I dragged and dropped the page branches around the page tree. PW’s link abstraction always correctly modified the links in the body-field.

Then I installed Multisite, and link abstraction unfortunately stopped working. When trying to save a page with any link in the body-field, PW displayed an error message like »Session: Unable to resolve link on page "pagename" in field "body": /link-to-another-page/«.

PW’s link abstraction internally saves page-ids as link-attributes in the database, like this:

<p>This is an <a	data-pwid=1023	href="/child-page-1/grandchild-page-2/">internal link</a>.</p>

When Multisite converts links like »/www.example.com/child-page-1/« to »/child-page-1/«, PW isn't able to recognize them anymore and therefore cannot save the corresponding page-ids to the database. So I assume, link abstraction won't work together with Multisite.

A powerful feature of Multisite is, that editor users see the »real« links in the backend. Modifying the links on page render, as you suggested in a previous post, would confuse those users, because they would see links like »/www.example.com/child-page-1/« in the WYSIWYG-Editors.

The only solution I can think of right now, would be to convert all modified links back to the original links on page save, let link abstraction do it’s work, and modify them again, when displayed in the backend or frontend.

Do you think that would be possible?

Share this post


Link to post
Share on other sites

Sorry, there's so many iterations and experiments with this module I can't always recall what the current state is. I'm working on and off on this.

I forgot the current dev still does alter the urls to strip out the domain segment. So as you seen, PW isn't able to resolve the url anymore. This also created various problems not only with link abstraction, but page path history view links etc etc.

Current version I have, works fine here due to NOT rewriting anything in the backend (ready() hooks all commented out + some parsing of the urls on page render). So the only headache free and correct solution is to let them as is. A "/domain1/about/" vs a "/about/" also has some advantage in that it's the physical url and can be recognized and handled in some way if needed while the latter you can't. Domain1 and Domain2 could have both a "/about/" and you don't know which one is which. I guess it's not something we have many options unfortunately.

I'm still testing and working on the new version, but have no ETA.

So this modules is still in "alpha" and each version may not compatible with one or another previous version (also PW versions) and I still do not recommend using it in a important or critical project and only if you're aware of the consequences it may bring (broken links you can hardly recover).

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the detailed explanation of the new module version!

Some time ago, I wrote a simple module for a client website that converted every href-value on page render. It stripped out a certain folder name, i.e. it converted »/container-1/page-1/« to »/page-1/«.

That worked fine, but for my client it caused a really big usability issue in the backend, because they saw the original links in the WYSIWYG-Editor, and not the resulting links.

As much as I understand, the new Multisite version will also leave the original links in the WYSIWYG-Editors, like »/www.example.com/about/« instead of »/about/«.

Do you see any way to just display the »right« links to backend users, while not really altering them?

Share this post


Link to post
Share on other sites
1 minute ago, nurkka said:

Thanks for the detailed explanation of the new module version!

Some time ago, I wrote a simple module for a client website that converted every href-value on page render. It stripped out a certain folder name, i.e. it converted »/container-1/page-1/« to »/page-1/«.

That worked fine, but for my client it caused a really big usability issue in the backend, because they saw the original links in the WYSIWYG-Editor, and not the resulting links.

As much as I understand, the new Multisite version will also leave the original links in the WYSIWYG-Editors, like »/www.example.com/about/« instead of »/about/«.

Do you see any way to just display the »right« links to backend users, while not really altering them?

Maybe someone enlighten me here. But unfortunately it's not an easy one. Not one I can think of I would be happy with. Not one that doesn't create all the problems I'm trying to solve or stay away.

The problem with your idea is that it's not the saving and loading of the urls in the RTE but you're talking about the url field you see when selecting a page. That's the page linke editor that works together with a each PW specific RTE plugin editor on top of that. 

1. So, one and easy way would be to alter the $page->url via a hook (as it is now or was), but that's where it will be systemwide changed and many things may and will stop working. Maybe some options there to only alter if-then... but believe me it creates a whole tale of issues that arise in one place or another. Mixing it up with "here you do it but there you don't" etc. 

2. The other would to explore the PageEditLink module and probably only JS side to see if it can be somehow hidden, but by not altering the -in and -output. That would be more a cosmetic fix. I'm sure there would e some way or another, although not that easy. While I understand what you're saying that it creates usability issues, I think it can also create problems if you hide something that's relevant information too. Imagine you only see "/about"/ and "/about/" but which is which? We have lot of editors that edit multiple sites and cross linking should be easy. Maybe best way would be to "grey it out" and make them aware that it's "secondary" info due to multisite.

The other "problem" here is that it would have to be done for all RTE's etc and upcoming link editor plugins. And as it looks one would have to completely replace some of the complex PW RTE plugins and or the link editor js to make it work, and always try to incorporate changes and new features in the core that will occur in no time for sure (and then there's front-end editing).

So it's also a question of how deep this modules should go or stay out of the way and don't create too much dependencies.

Share this post


Link to post
Share on other sites

Hi,

I am to decide which CMS to choose for a future project. I have read and tried the MultiSite module, but I think PW won't be the choice, which I regret greatly! I cannot afford too much uncertainty. I love so much PW though! It won't be Drupal. 

I just want to point here a module made for Concrete 5, which I haven't tried yet (I will wait to see if we obtain the contract). That guy seems to have solved all obstacles. Maybe some of you would be inspired by it:  https://www.concrete5.org/marketplace/addons/multiple-domains1. Concrete 5 works differently than PW, but they do share the "tree" approach.

Another solution would be MODX and it's context feature.

Anyway, just my two cents.

Share this post


Link to post
Share on other sites

That plugin for c5 seems to do exactly same approach and share same issues. It mentioned as for simple use cases. Only difference is that their plugin costs 80 bugs.

Share this post


Link to post
Share on other sites
Just now, Soma said:

...80 bugs.

By far many more than multisite module for PW (haven't encountered many bugs in all the years).

And also more expensive :D 

  • Like 1

Share this post


Link to post
Share on other sites

I've used first apeisa's and later on soma's multisite in several installs. Latest versions rocks. Easy by code configurable module. You won't need to be uncertain about the multi site set-up. Not sure about 5.4 php requirement ^_^

Share this post


Link to post
Share on other sites

I don't mind paying $80 on a $60000 project, specially if I can get a swift support. I was just pointing some direction. As of sharing same issues, I can't talk about it right now. The main concern is not just the URL redirection, but the permissions associated with a subdomain.

My client asks that a role associated to a subdomain must be able to just edit the pages of that subdomain. There will be 10 subdomains (this is an international site with 10 region subdomains, sharing a lot of information in each site, but having also regional particularities. The only differences as for the templates will be the colour identifying the region). So far, in my understanding of PW, roles permission are template based (or user based with one of Ryan's module). I have seen a Page per role permission module, but it seems not ready for PW3. It's certainly doable to make some coding here to prevent edit pages (from the admin interface, since everybody will see the tree of the organisation).

In Concrete5 you can set permissions to a specific page in a tree and tells that the children share those permissions.

Anyway, Concrete5 and MODx are fine CMS, but I would like to stick to PW if I can, :-) , because the easiness of rendering and searching things, etc.

 

Just a final note. I'm not a program, but I'm part of a team with programmers. Programming things is not the problem. I am responsible to find the right solution for the project.

Share this post


Link to post
Share on other sites
33 minutes ago, Guy Verville said:

I don't mind paying $80 on a $60000 project, specially if I can get a swift support. I was just pointing some direction. As of sharing same issues, I can't talk about it right now. The main concern is not just the URL redirection, but the permissions associated with a subdomain.

My client asks that a role associated to a subdomain must be able to just edit the pages of that subdomain. There will be 10 subdomains (this is an international site with 10 region subdomains, sharing a lot of information in each site, but having also regional particularities. The only differences as for the templates will be the colour identifying the region). So far, in my understanding of PW, roles permission are template based (or user based with one of Ryan's module). I have seen a Page per role permission module, but it seems not ready for PW3. It's certainly doable to make some coding here to prevent edit pages (from the admin interface, since everybody will see the tree of the organisation).

In Concrete5 you can set permissions to a specific page in a tree and tells that the children share those permissions.

Anyway, Concrete5 and MODx are fine CMS, but I would like to stick to PW if I can, :-) , because the easiness of rendering and searching things, etc.

 

Just a final note. I'm not a program, but I'm part of a team with programmers. Programming things is not the problem. I am responsible to find the right solution for the project.

Hi, i haven't used ProcessWire in a multisite context but have already used the Admin Restrict Branch module to limit  to a given subpages set of theProcessWire page tree.

Edited by Nicolas
Corrected a typo
  • Like 1

Share this post


Link to post
Share on other sites

Thank you to pointing that. This plugin is doing exactly what I was hoping for :-)  After further essays, nope... while the page tree is truncated on login, users have still access to the entire site tree if they click on the page tree icon. I will make other tests.

Share this post


Link to post
Share on other sites

@Guy Verville - I would really like to know if Admin Restrict Branch works in multisite mode. I expect it should work just fine.

I use it in what sounds like a very similar situation to yours - I have the same set of pages and templates for regional/project specific branches of the page tree. With that module I simply give everyone access to everything on the home template and let inheritance provide access to all templates below and the module takes care of keeping users completely restricted to their regional branch - they can't even see the other branches (or any other pages outside their specific branch).

If you find any problems in multisite mode please let me know and I'll see what I can do about supporting it.

Share this post


Link to post
Share on other sites
18 minutes ago, Guy Verville said:

After further essays, nope... while the page tree is truncated on login, users have still access to the entire site tree if they click on the page tree icon. I will make other tests.

Sounds like something isn't quite right - if I click the page tree icon, they still get the same restricted branch. Are you talking about the icon to the left of "Pages"?

Screen Shot 2016-10-08 at 3.54.01 PM.png

When I click that, I still get the restricted branch in the panel, like so:

Screen Shot 2016-10-08 at 3.55.15 PM.png

Is this what you are talking about, or something else?

Share this post


Link to post
Share on other sites

Well, perhaps the first time, I didn't enter the site correctly. I can see the branch, but can't edit anything.

I have created a role "nord" (for north region), which has the page-edit permission. I then created a user with that role only set. When I enter the site with that user, I see only the "nord" branch.

OperaScreenSnapz002.pngOperaScreenSnapz001.png

Share this post


Link to post
Share on other sites

Sorry, my bad. I forgot to apply correctly the page-edit permission to the template! It works.

OperaScreenSnapz003.png

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, Guy Verville said:

Sorry, my bad. I forgot to apply correctly the page-edit permission to the template! It works.

OperaScreenSnapz003.png

Nice, although I assume that second screenshot is with superuser logged in since it shows all branches?

PS - don't forget what I mentioned earlier on about just applying access permissions to the home template and no others - if you are using this module it simplifies things a lot.

 

Share this post


Link to post
Share on other sites

No, I just played with the settings, since you can allow user to see all the branches but edit just some.

  • Like 1

Share this post


Link to post
Share on other sites

However, while visiting the domain and the subdomain (pw.local, and nord.pw.local), it seems to bring cookies problem. I will have to investigate this. I tried to set the restriction by Role, and it does not seem to work. I can edit everything.

Share this post


Link to post
Share on other sites
1 minute ago, Guy Verville said:

it seems to bring cookies problem. I will have to investigate this.

Please let me know what you find out.

 

1 minute ago, Guy Verville said:

I tried to set the restriction by Role, and it does not seem to work. I can edit everything.

Are you talking about the "Role Name" matching option? I think some people haven't understood this option properly. It's what I use all the time for my sites, but to be clear, in your case you'd want the name of the role to be "page-nord" to match the name of the page that is the parent of the branch you are restricting them to. Does that help, or is that what you are already doing? Or maybe you found a bug?

Share this post


Link to post
Share on other sites

ok, I understand. The role must match the page. The multisite module needs the branches to be set on the url name. For our example, it's nord.pw.local. The role should be then nord.pw.local? 

Addendum: it seems to not work.

Share this post


Link to post
Share on other sites
16 minutes ago, Guy Verville said:

ok, I understand. The role must match the page. The multisite module needs the branches to be set on the url name. For our example, it's nord.pw.local. The role should be then nord.pw.local? 

Addendum: it seems to not work.

I just tested that exact name for the name of the parent page and also the role name and it is working fine here, so it should work for you from what I can tell.

Perhaps a multilanguage issue - is the name of the page in all languages set to nord.pw.local ?

Share this post


Link to post
Share on other sites

The title of the page is different from its path. There are now multilingual settings here. Have you tried with the multisite installed?

Share this post


Link to post
Share on other sites

Ok, i think I got it. When setting to "Role Name", the root of the site must be select.

Share this post


Link to post
Share on other sites
1 minute ago, Guy Verville said:

Ok, i think I got it. When setting to "Role Name", the root of the site must be select.

Do you mean the "Parent to restrict Role Name and Custom PHP code matches to." setting? 

That setting is completely optional, but the key thing is that obviously it must be above all the branches to be restricted. If your branches to be restricted are direct children of Home, then there isn't much point in this setting. It really only comes into play if they are several levels down as it reduces the page selector to that tree. You can see how it works here: https://github.com/adrianbj/AdminRestrictBranch/blob/15c70b90144fa68cafed0cdbb2d802e5dcfa1f2c/AdminRestrictBranch.module#L236 - see how $branchesParentSelector is defined using the "has_parent" selector.

Anyway, that setting isn't relevant to you and it sounds like you have everything working correctly?

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-07-03 -- SnipWire 0.8.7 (beta) released! Fixes some small bugs and adds an indicator for TEST mode 2020-04-06 -- SnipWire 0.8.6 (beta) released! Adds support for Snipcart subscriptions and also fixes some problems 2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  

       
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By Sten
      Hello
      Till now I hacked something with the twig template but it works no more with new PW versions so I look forward to create a module. I am working on a site in multiple languages : French, English, Italian, German, Spanish, Portuguese, Hebrew, Russian. The new posts are entered in any language with a field for language. Till now, I got twig files to get the translations with constants defined for each part of the pages.
      So I'd like to create a module to include theses files added according to the url /fr/en/...
      Have you some observations to do before I begin about the direction to take ?
      Thank you
    • By ukyo
      Mystique Module for ProcessWire CMS/CMF
      Github repo : https://github.com/trk/Mystique
      Mystique module allow you to create dynamic fields and store dynamic fields data on database by using a config file.
      Requirements
      ProcessWire 3.0 or newer PHP 7.0 or newer FieldtypeMystique InputfieldMystique Installation
      Install the module from the modules directory:
      Via Composer:
      composer require trk/mystique Via git clone:
      cd your-processwire-project-folder/ cd site/modules/ git clone https://github.com/trk/Mystique.git Module in live reaction with your Mystique config file
      This mean if you remove a field from your config file, field will be removed from edit screen. As you see on youtube video.
      Using Mystique with your module or use different configs path, autoload need to be true for modules
      Default configs path is site/templates/configs/, and your config file name need to start with Mystique. and need to end with .php extension.
      Adding custom path not supporting anymore !
      // Add your custom path inside your module class`init` function, didn't tested outside public function init() { $path = __DIR__ . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR; Mystique::add($path); } Mystique module will search site/modules/**/configs/Mystique.*.php and site/templates/Mystique.*.php paths for Mystique config files.
      All config files need to return a PHP ARRAY like examples.
      Usage almost same with ProcessWire Inputfield Api, only difference is set and showIf usage like on example.
      <?php namespace ProcessWire; /** * Resource : testing-mystique */ return [ 'title' => __('Testing Mystique'), 'fields' => [ 'text_field' => [ 'label' => __('You can use short named types'), 'description' => __('In file showIf working like example'), 'notes' => __('Also you can use $input->set() method'), 'type' => 'text', 'showIf' => [ 'another_text' => "=''" ], 'set' => [ 'showCount' => InputfieldText::showCountChars, 'maxlength' => 255 ], 'attr' => [ 'attr-foo' => 'bar', 'attr-bar' => 'foo' ] ], 'another_text' => [ 'label' => __('Another text field (default type is text)') ] ] ]; Example:
      site/templates/configs/Mystique.seo-fields.php <?php namespace ProcessWire; /** * Resource : seo-fields */ return [ 'title' => __('Seo fields'), 'fields' => [ 'window_title' => [ 'label' => __('Window title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'attr' => [ 'placeholder' => __('Enter a window title') ] ], 'navigation_title' => [ 'label' => __('Navigation title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'showIf' => [ 'window_title' => "!=''" ], 'attr' => [ 'placeholder' => __('Enter a navigation title') ] ], 'description' => [ 'label' => __('Description for search engines'), 'type' => Mystique::TEXTAREA, 'useLanguages' => true ], 'page_tpye' => [ 'label' => __('Type'), 'type' => Mystique::SELECT, 'options' => [ 'basic' => __('Basic page'), 'gallery' => __('Gallery'), 'blog' => __('Blog') ] ], 'show_on_nav' => [ 'label' => __('Display this page on navigation'), 'type' => Mystique::CHECKBOX ] ] ]; Searching data on Mystique field is limited. Because, Mystique saving data to database in json format. When you make search for Mystique field, operator not important. Operator will be changed with %= operator.
      Search example
      $navigationPages = pages()->find('my_mystique_field.show_on_nav=1'); $navigationPages = pages()->find('my_mystique_field.page_tpye=gallery');
    • By Robin S
      This is a module I made as an experiment a while ago and never got around to releasing publicly. At the time it was prompted by discussions around using Repeater fields for "page builder" purposes, where the depth feature could possibly be used for elements that would be nested inside other elements. I thought it would be useful to enforce some depth rules and translate the depth data into a multi-dimensional array structure.
      I'm not using this module anywhere myself but maybe it's useful to somebody.
      Repeater Depth Helper
      This module does two things relating to Repeater fields that have the "Item depth" option enabled:
      It enforces some depth rules for Repeater fields on save. Those rules are:
      The first item must have a depth of zero. Each item depth must not be more than one greater than previous item depth. It provides a RepeaterPageArray::getDepthStructure helper method that returns a nested depth structure for a Repeater field value.
      Helper method
      The module adds a RepeaterPageArray::getDepthStructure method that returns a multi-dimensional array where the key is the page ID and the value is an array of nested "child" items, or null if there are no nested children.
      Example

      The module doesn't make any assumptions about how you might want to use the depth structure array, but here is a way you might use it to output a nested unordered list.
      // Output a nested unordered list from a depth structure array function outputNestedList($depth_structure, $repeater_items) { $out = "<ul>"; foreach($depth_structure as $page_id => $nested_children) { $out .= "<li>" . $repeater_items->get("id=$page_id")->title; // Go recursive if there are nested children if(is_array($nested_children)) $out .= outputNestedList($nested_children, $repeater_items); $out .= "</li>"; } $out .= "</ul>"; return $out; } $repeater_items = $page->my_repeater; $depth_structure = $repeater_items->getDepthStructure(); echo outputNestedList($depth_structure, $repeater_items);
       
      https://github.com/Toutouwai/RepeaterDepthHelper
      https://modules.processwire.com/modules/repeater-depth-helper/
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
×
×
  • Create New...