webhoes Posted September 3, 2017 Share Posted September 3, 2017 Hello, I am working on a website that has 4 domains. 3 are a alias to the main domain. I want to achieve the following. Home - domain A Child 1 of Home - domain B Child of child - domain B Child of child - domain B Child 2 of Home - domain C Child of child - domain C Child of child - domain C Child 3 of Home - domain D Child of child - domain D Child of child - domain D Basicly I made a website with a home and 3 onepager that contain different pages. How can I achieve that if you go from home to "Child 1 of Home - domain B" the domain changes in the url? Link to comment Share on other sites More sharing options...
monchu Posted September 3, 2017 Share Posted September 3, 2017 I'm not too sure it is doable or not, just an idea, you can read about multi sites here: https://processwire.com/api/modules/multi-site-support/ 1 Link to comment Share on other sites More sharing options...
arjen Posted September 3, 2017 Share Posted September 3, 2017 This is possible with the Multi-site module. Read through the whole thread. There is valuable info in it. You may need the restructure your tree a bit. 1 Link to comment Share on other sites More sharing options...
webhoes Posted September 3, 2017 Author Share Posted September 3, 2017 I looked at the multi-site module but was not sure I could do it with that. I will make a test setup. Is something like this possible? if($page->domain != this page url then force $page->url as domain Basicly if the domain does not equel that of the field then load the page with the corresponding domain of $page->domain Link to comment Share on other sites More sharing options...
webhoes Posted September 3, 2017 Author Share Posted September 3, 2017 It is solved finally. Used the multisite by @Soma I did not find in the documentation that I had to add all domains also to site/config.php. When I did that, all worked like a charm. 2 Link to comment Share on other sites More sharing options...
arjen Posted September 4, 2017 Share Posted September 4, 2017 Great @webhoes, that's why you should read the entire thread. I knew it had to be somewhere. Link to comment Share on other sites More sharing options...
webhoes Posted September 5, 2017 Author Share Posted September 5, 2017 I did not find it in the topic. Probably missed it. I you use a different domain to enter the admin you get an error. That was the hint to add them to the config.php... Link to comment Share on other sites More sharing options...
webhoes Posted October 3, 2017 Author Share Posted October 3, 2017 I have come across the following quirk. I redirect a 404 to the search so that a 404 is never given but a list of relevant pages. I just found out that this wil build an infinite loop. A page in the rootdomain will show up, but will have the domain you are currently (on of the muli sites) on. But page doens't excist on that domain so you go through the search again and again... Now I changed ->url to ->httpUrl but this doesn't take into account the orginal domain that page is from. Is there a way around this? Link to comment Share on other sites More sharing options...
abdus Posted October 3, 2017 Share Posted October 3, 2017 I don't think preventing 404s is a good idea. You can show an explanation + suggest some pages with keywords from the URL, or your popular pages etc. on 404 page too. https://moz.com/blog/are-404-pages-always-bad-for-seo Link to comment Share on other sites More sharing options...
webhoes Posted October 3, 2017 Author Share Posted October 3, 2017 I can also show the links on the 404 page. But how do I force the right domain for the search results in the list? Link to comment Share on other sites More sharing options...
abdus Posted October 3, 2017 Share Posted October 3, 2017 35 minutes ago, webhoes said: A page in the rootdomain will show up, but will have the domain you are currently (on of the muli sites) on. But page doens't excist on that domain so you go through the search again and again... Now I changed ->url to ->httpUrl but this doesn't take into account the orginal domain that page is from. If you dont want to show pages from other domain roots, you can add has_parent to limit returned pages to one domain only https://processwire.com/api/selectors/#finding2 Link to comment Share on other sites More sharing options...
webhoes Posted October 3, 2017 Author Share Posted October 3, 2017 Actually I do want that. It is ok if a page from another domain shows up in the list. But if you click on it, you should go to that page with the corresponding domain. Link to comment Share on other sites More sharing options...
abdus Posted October 3, 2017 Share Posted October 3, 2017 Perhaps prepend urls with $page->rootParent->httpUrl? (I haven't used multisite before) Can you post a screenshot of your page tree? Or the output from your code vs how you want it? Link to comment Share on other sites More sharing options...
webhoes Posted October 3, 2017 Author Share Posted October 3, 2017 this is the page tree The pages Over, Historie, etc should refer to the rootdomain (Home). All other search results should refer to the corresponding domain. All found pages should be in the search results and the links should jump to the corresponding page with correct domain. Otherwise the page doesn't excist. This is the basis search code (slightly adapted) function renderNav(PageArray $items) { // $out is where we store the markup we are creating in this function $out = ''; // cycle through all the items foreach($items as $item) { // render markup for each navigation item as an <li> if($item->id == wire('page')->id) { // if current item is the same as the page being viewed, add a "current" class to it $out .= "<li class='current'>"; } else { // otherwise just a regular list item $out .= "<li>"; } // markup for the link $out .= "<a href='$item->httpUrl'>$item->title</a> "; // if the item has summary text, include that too if($item->summary) $out .= "<div class='summary'>$item->summary</div>"; // close the list item $out .= "</li>"; } // if output was generated above, wrap it in a <ul> if($out) $out = "<ul class='nav'>$out</ul>\n"; // return the markup we generated above return $out; } Link to comment Share on other sites More sharing options...
adrian Posted October 3, 2017 Share Posted October 3, 2017 1 hour ago, webhoes said: I redirect a 404 to the search so that a 404 is never given but a list of relevant pages. This module will take care of this for you: http://modules.processwire.com/modules/process404-search/ 53 minutes ago, abdus said: I don't think preventing 404s is a good idea. It still returns a proper 404 header, although I am no longer convinced this module/technique is a good idea: https://processwire.com/blog/posts/optimizing-404s-in-processwire/ Link to comment Share on other sites More sharing options...
webhoes Posted October 3, 2017 Author Share Posted October 3, 2017 I use that module for this. But I need full links with the proper full url in the search results. I will check your second link and update my knowledge... Link to comment Share on other sites More sharing options...
adrian Posted October 3, 2017 Share Posted October 3, 2017 13 minutes ago, webhoes said: But I need full links with the proper full url in the search results. What it returns is what your search.php template file returns - if you tweak that to return ->httpUrl you will get what you're looking for. In mine for example: foreach($viewableMatches as $m) { $content .= '<p><a href="'.$m->httpUrl.'">' . $m->parent->title . ' > ' . $m->title . '</a></p>'; } Link to comment Share on other sites More sharing options...
webhoes Posted October 3, 2017 Author Share Posted October 3, 2017 I have this.. but that does not seem to get the correct full url. It still makes links the only have the url that you are on at the moment. The search results all belong to another domain. That is what I want, but the httpUrl should get corresponding domain of that particular page in the search results. // markup for the link $out .= "<a href='$item->httpUrl'>$item->title</a> "; What does the parent->title do for you. You have more closing tags then opening tags... Link to comment Share on other sites More sharing options...
adrian Posted October 3, 2017 Share Posted October 3, 2017 It's not an extra ">" tag - it's a string and makes the link look like a breadcrumb, eg. Furniture > Chairs As for the other domain issue you are having - sorry I haven't ever used the multisite module, so not the best person to help on that side of things. Link to comment Share on other sites More sharing options...
webhoes Posted October 3, 2017 Author Share Posted October 3, 2017 Nice, I did not look close enough... my bad. It is my first time too. I also did not foresee this as an issue... Link to comment Share on other sites More sharing options...
Robin S Posted October 4, 2017 Share Posted October 4, 2017 @webhoes, I haven't used the Multisite module, but the readme you should have defined separate 404 pages for each domain. So this kind of setup is probably not compatible with Process404Search out-of-the-box. But based on this section of the readme... Quote Just create pages with names like www.campaigndomain.com unter the root page and add these in the config.php via an array in $config->MultisiteDomains. ...you should be able to get the correct links by modifying the search.php adrian refers to above: foreach($viewableMatches as $m) { $url = "{$input->scheme}://{$m->rootParent->name}/{$m->url}"; $content .= "<p><a href='$url'>$m->title</a></p>"; } Not tested. Also note that your page tree... On 04/10/2017 at 12:27 AM, webhoes said: this is the page tree ...is what the Multisite readme says not to do: Quote TroubleShooting Wrong page tree structure - Homepage (main site home) - Example Page - 404 Page - Contact Page - www.domain2.com (a second site home) - 404 Page ... But this wasn't ever recommended and it can lead to complications. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now