Forums / All Other Contributions/Addons / MultiSite Module Support Thread

MultiSite Module Support Thread

Started by gerome on 23 Apr 2007, 10:24 AM · Views: 581,865

Results 181 to 200 of 2,247
16 Aug 2007, 2:24 PM
#181
jvoce avatar

jvoce

New Zenner

Join Date:
Jul 2006
Location:
Toronto, ON
Posts:
87
Plugin Contributions:
0

MultiSite Module Support Thread

Gerome:

Hi Jvoce,

You still need to add that at the begining of your 'configure.php':

include_once('includes/config_sites/sites_switch.php');


I can't believe I missed something that obvious. Many thanks!
16 Aug 2007, 4:44 PM
#182
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Gerome:

This is strange, this page work well for me.

Could you check your file:
includes/modules/pages/products_new/header_php.php

Line 34 should be:

$products_new_split = new splitPageResults(cat_filter($products_new_query_raw), MAX_DISPLAY_PRODUCTS_NEW);


Gerome you are right on clean zencart installation all working fine.
I have a heavy modified version of zencart . I have merged all my addons again and find the bug that caused the problem with  the new product listing.

Thanks!!
16 Aug 2007, 5:08 PM
#183
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Tip:

If you want a different index welcome page in each site you can do something like this.

File:includes/config_sites/sites_switch.php

after

$default_server_name = $_SERVER['HTTP_HOST'];

add

	$default_server_name1 = 'www.site1.yoursite.com';
	$default_server_name2 = 'www.site2.yoursite.com';
	$default_server_name3 = 'www.site3.yoursite.com';

File:includes/modules/pages/index/header_php.php

Line 42

from

 $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_MAIN_PAGE, 'false');

to

if($_SERVER['HTTP_HOST'] == $default_server_name1 ){
 $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_1, 'false');
 }elseif($_SERVER['HTTP_HOST'] == $default_server_name2 ){
 $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_2, 'false');
 }elseif($_SERVER['HTTP_HOST'] == $default_server_name3 ){
 $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_3, 'false');
 }else{
 $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_MAIN_PAGE, 'false');
 }

You can edit then the page_1,page_2,page_3 from admin define pages editor.

Or you can specific other pages there from ez pages tool.

17 Aug 2007, 8:29 AM
#184
magnus_wester avatar

magnus_wester

New Zenner

Join Date:
Jul 2007
Location:
Stockholm, Sweden and Palermo, Italy
Posts:
6
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Gerome:

Magnus,
Thank you so much for you for your post !! This is of a great help.
I guess I should add that to the documentation of the module right ?

Hi Gerome,
I'm happy you liked my "MultiSite Module for Dummies" contribution. Here is another section for your documentation:

Consider how you will handle http 404 Not Found errors

As a good webmaster, you are never the source of a "page-not-found" error. You regularly use a link checker to verify that the linking structure of your web site is intact. You verify your web server log for 404 errors coming from external links pointing to non-existent pages on your site.

When the URL for a page needs to be corrected, you redirect requests for the old or incorrect location to the new location of the page. On the rare occasion when you just remove a page, you insert a "Page removed" page for human visitors that also gives a 410 "Gone" status to search engine spiders.

For good webmasters, "page-not-found" errors can only occur because someone typed in an incorrect URL into the address bar of their browser. Many sites intercept such errors using a 404 script. If your .htaccess file contains

ErrorDocument 404 /http404.php
```the http404.php script will be executed for each request for a non-existent page.

Since you're now using the MultiSite module, you once again need to know what domain you're in so that you show the right "not-found" page. Here is an example of a http404.php script that handles the situation differently depending on the site:

// http 404 not found error handler for multisite installations.
// The http 404 status is already set here.
// Just call the right page for the current site.

switch($_SERVER['HTTP_HOST']) {
case 'site1.com':
require('http://site1.com/zencart/index.php?main_page=page_not_found');
break;
case 'site2.com':
require('http://site2.com/en/pages/not-found/');
break;
case 'site3.com':
require('http://site3.com/page-not-found.php');
break;
}

// Make sure that code below does not get executed when we redirect.
exit;

http://<domain>/<path>/index.php?main_page=<page>


However, Zen Cart does not automatically intercept any errors in the <domain> or <path> segments of the URL. That's why you need a separate 404 error script like the one described above.
17 Aug 2007, 10:46 AM
#185
magnus_wester avatar

magnus_wester

New Zenner

Join Date:
Jul 2007
Location:
Stockholm, Sweden and Palermo, Italy
Posts:
6
Plugin Contributions:
0

Re: MultiSite Module Support Thread

stav:

Tip:
If you want a different index welcome page in each site you can do something like this.

Hi Stav,

I'm new here and I may be mistaken, but there is already a unique starting page pe r site at

includes/languages/ENGLISH/SITENAME/index.php
```
(change the language and template name as required). 

As long as your Zen Cart is in the root folder of your site, this will be the site-unique starting page for each site, thanks to the way the Zen Cart and the MultiSite Module works. If I'm incorrect, please let me know what situation your solution handles that isn't already supported by the default setup - as I said I'm really new here.

A special case is of course when the Zen Cart is NOT in the root folder of the site. Obviously, you cannot do anything in the Zen Cart to handle this situation, since it doesn't know about anything that happens outside it's own folders. Instead, you will have to use something similar to my PHP script above to show the right index page for each site.
17 Aug 2007, 11:45 AM
#186
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Magnus Wester:

Hi Stav,

I'm new here and I may be mistaken, but there is already a unique starting page pe r site at

includes/languages/ENGLISH/SITENAME/index.php

> (change the language and template name as required).

That is the languages definitions for the index page,the most of the index texts content is stored in that page.

But if you go in admin/tools/define pages editor and there select from the dropdown menu the define_main_page.php.

Here you can specific anything on the top of the index page body content, you can use and WYSIWYG edotor in this page content.

In admin/tools/define pages editor  are 4 empty pages too, page_1, page_2 , page_3 and page_4.

So i used that pages for each of my sites for main page contents welcome messages intro images etc.
17 Aug 2007, 12:10 PM
#187
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Magnus Wester:

In this case you probably need a separate index page for each site. To achieve this, you need to create a script. I use PHP, and this is my new index.php file:

<?php switch($_SERVER['HTTP_HOST']) { case 'site1.com': require('site1-index.php'); break; case 'site2.com': require('site2-index.php'); break; case 'site3.com': require('site3-index.php'); break; } ?>
> This uses the same technique as the MultiSite Module to show different content for different sites by using a separate index.php file for each site. From this site-unique file you create each site with its own content, templates, CSS files etc.


I dont't know why you need different zencart_root/index.php pages for each site.

I think that you need just different text definitions for each site on the index page.
So you can do that if you put into languages/yourlanguage/name_of_the_site1_template/index.php
languages/yourlanguage/name_of_the_site2_template/index.php
languages/yourlanguage/name_of_the_site3_template/index.php

and then using my previous post for the define_main_page.php

You can have a totall diferents index or other pages for each site using diferrent template and languages definitions for each site.
17 Aug 2007, 2:56 PM
#188
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: MultiSite Module Support Thread

The tip that I posted about define_main_page.php , is usefull that you can edit the define_main_page.php from the admin tool for all the sites, and you can changing that content anytime you like.

You can do the same thing using different laguage definitions files in
includes/languages/yourlanguage/html_includes/name_of_the_site1_template/define_main_page.php

includes/languages/yourlanguage/html_includes/name_of_the_site2_template/define_main_page.php
etc. but you must edit manualy that pages except the default define_main_page.php which you can edit from the admin defines pages editor.

17 Aug 2007, 3:04 PM
#189
gerome avatar

gerome

Zen Follower

Join Date:
Sep 2006
Posts:
100
Plugin Contributions:
0

Re: MultiSite Module Support Thread

stav:

The tip that I posted about define_main_page.php , is usefull that you can edit the define_main_page.php from the admin tool for all the sites, and you can changing that content anytime you like.

You can do the same thing using different laguage definitions files in
includes/languages/yourlanguage/html_includes/name_of_the_site1_template/define_main_page.php

includes/languages/yourlanguage/html_includes/name_of_the_site2_template/define_main_page.php
etc. but you must edit manualy that pages except the default define_main_page.php which you can edit from the admin defines pages editor.

You can Edit the file for each template from the admin section by changing the template from the admin section (this won't change the template front end) using Tools -> Templates Selection.

Using the Define pages is the best way of creating extra pages for the website and let the possibility to the admin to change the content...

17 Aug 2007, 4:47 PM
#190
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: MultiSite Module Support Thread

You can Edit the file for each template from the admin section by changing the template from the admin section (this won't change the template front end) using Tools -> Templates Selection.
Yeas right my mistake :).

17 Aug 2007, 6:53 PM
#191
magnus_wester avatar

magnus_wester

New Zenner

Join Date:
Jul 2007
Location:
Stockholm, Sweden and Palermo, Italy
Posts:
6
Plugin Contributions:
0

Re: MultiSite Module Support Thread

stav:

I dont't know why you need different zencart_root/index.php pages for each site.

No, as I wrote in my post you don't.

But if your Zen cart is in a folder, it has nothing to do with the index page in the root folder. And then you need a different solution, outside the Zen Cart environment.

20 Aug 2007, 7:27 AM
#192
streetglow avatar

streetglow

New Zenner

Join Date:
Aug 2006
Posts:
38
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Now is the day that I release the EZPages Filter.

Sadly I haven't made the admin tool "release-ready".

Attachment #2504

All the shops must use the same currency.

Hmm... really?!
I don't really believe so.
I have made a kind of simulation mode which I can turn on or off in every shop connected to the same database.
This simulation mode simulates array containing the input I want for that shop.
Try debugging a few things...

For example:
What is the currencies variable?
All the info is pumped into this currencies variable by an array.
Simply use the function "print_r();" to see what's inside the array, with this data you can "simulate" the array but now with other data.
Give it a try :-)

20 Aug 2007, 9:51 AM
#193
magnus_wester avatar

magnus_wester

New Zenner

Join Date:
Jul 2007
Location:
Stockholm, Sweden and Palermo, Italy
Posts:
6
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Hi Streetglow,

Perhaps you should post your contribution at http://www.zen-cart.com/index.php?main_page=add_contrib? If you change your module name to begin with "Multisite" and you store it in the "Other modules" category it will end up next to the Multisite Module itself.

Regarding the currency in the shopping basket: all multisite shops share the same shopping basket. I don't believe it's safe to mix currencies in a shopping basket. At least I'm pretty sure that most backend systems haven't been tested for that. That's why I said that all shops should use the same currency. I don't know if it works technically anyway, but I believe it should be avoided.

20 Aug 2007, 10:01 AM
#194
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: MultiSite Module Support Thread

What's New Scrollbox 1.3 xhtml Filter

You can get it from here

After download the sidebox

Oen File: tpl_whats_new.php

Line 54
Find

  $random_product_query = "select products_id, products_image, products_tax_class_id, products_price
                           from " . TABLE_PRODUCTS . "
                           where products_status = '1'
                           order by products_date_added desc
                           limit " . MAX_RANDOM_SELECT_NEW;

	//var_export($random_product);
	
	$random_product = $db->Execute($random_product_query);

and replace with

  $random_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price
                           from " . TABLE_PRODUCTS . " p
                           where p.products_status = '1'
                           order by p.products_date_added desc
                           limit " . MAX_RANDOM_SELECT_NEW;

	//var_export($random_product);
	
	$random_product = $db->Execute(cat_filter($random_product_query));
20 Aug 2007, 10:07 AM
#195
streetglow avatar

streetglow

New Zenner

Join Date:
Aug 2006
Posts:
38
Plugin Contributions:
0

Re: MultiSite Module Support Thread

At least I'm pretty sure that most backend systems haven't been tested for that.

I agree with that, but as I always say:
"A code that hasn't been tested yet, doesn't and will not work".

I've been modifieing Zen Cart since 2006, so I pretty well know what I'm doing. So I agree with the fact if you don't know what you are doing, don't try it.

My currency modification only shows the customer in the currency he want.
For example there are 2 different shops, one for in Brittain and the other for the rest of the EU who has the Euro.
In the UK shop it shows pounds, in the EU shop it shows Euro. But in the backend system it shows the currency where the shop owner is from, in my case it will be euro.

It is possible to have different currencies, but not supported by this module (yet). Believe me... it will take a lot modification and time to archieve supporting different currencies.

20 Aug 2007, 6:36 PM
#196
jvoce avatar

jvoce

New Zenner

Join Date:
Jul 2006
Location:
Toronto, ON
Posts:
87
Plugin Contributions:
0

Re: MultiSite Module Support Thread

I've been able intigrate the MultiSite Module quite well with my online test stores: 1 2.

The only ability I'm still struggling with is trying to filter customers. All customers should be able to access store1, and only authorized customers should be able to access store2.

In Post 121 I was given this lead: > Gerome:

constants define tables; you can override these constants (TABLE_CUSTOMERS, ...) from the confg files of your sites, and then have different tables for different sites

Basically what I'm looking for is 1 of two things, either we are able to manually enter the authoized customer's email/ID No. or automatically authorizing anyone with a specific e-mail address ending (ex. @hotmail.com).

Any and all help is greatly appreciated as this will help our various locations around the country. And we are always kept on a tight budget being a charity.

Blessings,

20 Aug 2007, 7:01 PM
#197
streetglow avatar

streetglow

New Zenner

Join Date:
Aug 2006
Posts:
38
Plugin Contributions:
0

Re: MultiSite Module Support Thread

jvoce:

I will have to do out of my head since I'm at home now and not even willing to think about accessing my work's FTP, so sorry if I'm wrong about something...

This is exactly an aspect which I will have to work out very soon.
It can't be that hard tho, I believe if you make another field in the table customers called "customers_allowance" with the option "TEXT".

Then you will have to search the query which logs the customer on your site.
Also not that hard to locate "includes/modules/pages/login/header_php.php".
Edit the query which verifies the customer with the data inside the table.
Add " AND customers_allowance = '-%".SITE_NAME."%-' to it.

All that's left is creating an admin tool.
I can't help you with that yet...

21 Aug 2007, 1:27 PM
#198
jvoce avatar

jvoce

New Zenner

Join Date:
Jul 2006
Location:
Toronto, ON
Posts:
87
Plugin Contributions:
0

Re: MultiSite Module Support Thread

streetglow:

So what I've done thus far:

  1. SQL Command: ALTER TABLE customers ADD customers_allowance TEXT NOT NULL;

2)Added red text below to includes/modules/pages/login/header_php.php

  $check_customer_query = "SELECT customers_id, customers_firstname,  customers_password,
                                          customers_email_address, customers_default_address_id,
                                          customers_authorization, customers_referral
                                          FROM " . TABLE_CUSTOMERS . "
                                          WHERE customers_email_address = :email
	   AND customers_allowance = '-%".SITE_NAME."%-'";

Now obviously, I assume I'll need to place text in the database to allow some customers complete access. Something as simple as Yes or No should do?

The next question is how would I go about setting the site switch for that?

21 Aug 2007, 1:34 PM
#199
streetglow avatar

streetglow

New Zenner

Join Date:
Aug 2006
Posts:
38
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Sorry my bad, ofcourse it shouldn't be "=" but "LIKE".

$check_customer_query = "SELECT customers_id, customers_firstname, customers_password,
customers_email_address, customers_default_address_id,
customers_authorization, customers_referral
FROM " . TABLE_CUSTOMERS . "
WHERE customers_email_address = :email
AND customers_allowance LIKE '-%".SITE_NAME."%-'";

In the text field you should add the names of your sites delimited by "--".
Example:

--domain1.com--domain2.com--domain3.com--

Thats it.

21 Aug 2007, 3:39 PM
#200
jvoce avatar

jvoce

New Zenner

Join Date:
Jul 2006
Location:
Toronto, ON
Posts:
87
Plugin Contributions:
0

Re: MultiSite Module Support Thread

streetglow:

In the text field you should add the names of your sites delimited by "--".
Example:

--domain1.com--domain2.com--domain3.com--

Okay just a couple of more questions for you.
I don't have access to the database admin screen, so I sometimes feel a little limited not being able to really edit or experiement with the tables.

I'd like to set a default for the customers_allowance field to access one or two of the sites. What would I need to add to the previously used SQL command?

ALTER TABLE customers ADD customers_allowance TEXT NOT NULL;

Second question is what SQL Command would I need to enter when someone is given permission to access the more restricted site?

Thanks again for your patience and help. It's grealy appreciated!