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 201 to 220 of 2,247
21 Aug 2007, 5:18 PM
#201
streetglow avatar

streetglow

New Zenner

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

MultiSite Module Support Thread

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?

Unfortunately setting a default for the TEXT type isn't possible.

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

Simply an update query with the correct parameters.

For example (if you add another field in the "edit customer", admin) the field in the form is called "site".

Just do this query then:

$field_customers_allowance = '--';
$field_customers_allowance = $_POST['site'];
$field_customers_allowance . '--';
mysql_query("UPDATE customers SET customers_allowance = '".$field_customers_allowance."'" WHERE customers_id = '".$_GET['cID']."');

That will be it.

21 Aug 2007, 7:38 PM
#202
jvoce avatar

jvoce

New Zenner

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

Re: MultiSite Module Support Thread

Alright, after having spent a while working on this problem, I found a much easier solution. I actually gave it a try earlier, but I didn't quite have it all together.

Problem:
I have 2 sites. 1 site is open for the public to view, and the 2nd is only for authoirzed personnel to view, and purchase. All customers should be able to shop on the public site immediately without any hold up.

Solution:
1)Admin>Customer Details>Customer Approval Status - Authorization Pending Set to 1

2)Config site switch for public store as such ```
define('CUSTOMERS_APPROVAL_AUTHORIZATION','0'); //Customer Approval Status - Authorization Pending


3)Edit includes/modules/create_account.php
$sql_data_array = array('customers_firstname' => $firstname,
                        'customers_lastname' => $lastname,
                        'customers_email_address' => $email_address,
                        'customers_nick' => $nick,
                        'customers_telephone' => $telephone,
                        'customers_fax' => $fax,
                        'customers_newsletter' => (int)$newsletter,
                        'customers_email_format' => $email_format,
                        'customers_default_address_id' => 0,
                        'customers_password' => zen_encrypt_password($password),
                        'customers_authorization' => (int)CUSTOMERS_APPROVAL_AUTHORIZATION
);
Change to:
$sql_data_array = array('customers_firstname' => $firstname,
                        'customers_lastname' => $lastname,
                        'customers_email_address' => $email_address,
                        'customers_nick' => $nick,
                        'customers_telephone' => $telephone,
                        'customers_fax' => $fax,
                        'customers_newsletter' => (int)$newsletter,
                        'customers_email_format' => $email_format,
                        'customers_default_address_id' => 0,
                        'customers_password' => zen_encrypt_password($password),
                        'customers_authorization' => 1
);


Result:
Customer will not be automatically approved by the main settings, but the public site doesn't care if a customer is authorized.

Note:
Now as always be careful when adjusting the code to Zen, but this was the best solution that was suited for our needs.

Thank you streetglow for all your help!
22 Aug 2007, 8:31 AM
#203
streetglow avatar

streetglow

New Zenner

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

Re: MultiSite Module Support Thread

Your welcome.

Please beware that this will only suit for having 1 site unauthorized and the other site authorized. If you would have 3 different sites, with all 3 different authorizations (this is our case) you can only do it by or creating for every site a new variable definition or by using the method I described earlier.

Indeed, for your needs this was the easiest way to archieve it.

22 Aug 2007, 8:57 AM
#204
gerome avatar

gerome

Zen Follower

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

Re: MultiSite Module Support Thread

Ok, we need something more structured to develop this module, its instructions, documentation and tips and advice before it becomes too complicate and confusing.

I think that we should create a Multisite section in the zen-cart Wiki documentation

http://www.zen-cart.com/wiki/

Then everything will be clearer and make sense.

The only problem is that I don't know how to create an account for it or how to login ...

When you use something like:

... LIKE "-'.SITE_NAME.'-" ....

you only need one dash between the site names like that:

-site1-site2-site3-

This is how it feets into the description of the categories

<!--site1-site2-site3-->

however a double dash still works ! :lamo:

22 Aug 2007, 9:15 AM
#205
streetglow avatar

streetglow

New Zenner

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

Re: MultiSite Module Support Thread

The first site will not work, are my experiences. I might have made a typo.
But for preventing any issues I use double dash. Works fine.

Also if you use double dash you will be able to perform a PHP-function like "explode();" while this isn't possible with single dash.

22 Aug 2007, 10:20 AM
#206
gerome avatar

gerome

Zen Follower

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

Re: MultiSite Module Support Thread

streetglow:

The first site will not work, are my experiences. I might have made a typo.
But for preventing any issues I use double dash. Works fine.

Also if you use double dash you will be able to perform a PHP-function like "explode();" while this isn't possible with single dash.

for the first site, make sure you start by a dash.

Explode for "-site1-site2-site3-":

$site_array=explode('-',trim($site_string,'-'));

But of course you can do as you wish ...

22 Aug 2007, 2:01 PM
#207
jvoce avatar

jvoce

New Zenner

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

Re: MultiSite Module Support Thread

Alright, I'm back with another problem, hopefully not every is sick of me yet.:blush:

I'm wanting to set up the site_links feature so the session ID and everything is working as it should. My problem I'm picky and it's not quite all that I'm looking for. :lookaroun

When someone who is authorized for the public site is signed in and clicks to visit the restricted site, they are automatically given full access to the restricted site. I'd like the people with customer_authorization of 1 to not be allowed full access but to the authorization pending page.

Essentially I need the customers_authorization to transfer along with the session_id. I assume this is not only controlled by the site_links sidebox, but also by the who's online table in the database. I'm I correct in my assumptions?

If so I guess I'll need to run

ALTER TABLE whos_online ADD customer_authorization int(1) default NULL;

Then edit the side box to carry the authorization value with it, but I'm not entirely sure where to place that.

I'm I on the right track?

22 Aug 2007, 3:04 PM
#208
jvoce avatar

jvoce

New Zenner

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

Re: MultiSite Module Support Thread

Okay, it's turns out that the site links do work for filter customer authorization 90% of the time, without any modification to the file or database.

The only case when it does not pay attention to the authorization value is just after a new customer has signed up. I'm not sure why that is though.

22 Aug 2007, 4:27 PM
#209
tieske avatar

tieske

New Zenner

Join Date:
Mar 2006
Posts:
23
Plugin Contributions:
0

Re: MultiSite Module Support Thread

1st: This Module is just what I was looking for. Thanks Gerome.

2nd: Implementing the module looks simple, but it doesn't work for me yet:

[QUOTE=Gerome;418983]Hi Jvoce,

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

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

QUOTE]

After making (and solving) the same mistake as above, now I'm facing the following problem:

The Admin still works fine, but opening the site gives the nddbc.html page (antiekbeslag.nl).

The database seems to work/connect normal...

It wasn't a fresh install, but I carefully merged the few files I changed.
(super orders in includes/classes/order.php;
includes/modules/product_listing.php:

$listing_split = new splitPageResults($listing_sql, $max_results, 'p.products_id', 'page');

Changed in:

$listing_split = new splitPageResults(cat_filter($listing_sql), $max_results, 'p.products_id', 'page');

Instead of:

$listing_split = new splitPageResults(cat_filter($listing_sql), MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');

(But both ways don't work)
)

Is there a simple mistake I'm overlooking? Does anybody have a clue what's obvious I did wrong?

Thanks in advance.

23 Aug 2007, 10:46 AM
#210
tieske avatar

tieske

New Zenner

Join Date:
Mar 2006
Posts:
23
Plugin Contributions:
0

Re: MultiSite Module Support Thread

I changed an old Configure.php file and after uploading the databaseconnection on the front-end didn't work....

Waste of some quality hours but now I'm ready to test the rest.

23 Aug 2007, 11:32 AM
#211
gerome avatar

gerome

Zen Follower

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

Re: MultiSite Module Support Thread

[quote=Tieske;421767]1st: This Module is just what I was looking for. Thanks Gerome.

2nd: Implementing the module looks simple, but it doesn't work for me yet:

Gerome:

Hi Jvoce,

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

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

> 
> 
> 
> After making (and solving) the same mistake as above, now I'm facing the following problem:
> 
> The Admin still works fine, but opening the site gives the  nddbc.html  page (antiekbeslag.nl).
> 
> The database seems to work/connect normal...
> 
> 
> 
> It wasn't a fresh install, but I carefully merged the few files I changed.
> (super orders in includes/classes/order.php;
>  includes/modules/product_listing.php:
> 
> $listing_split = new splitPageResults($listing_sql, $max_results, 'p.products_id', 'page');
> 
> Changed in:
> 
> $listing_split = new splitPageResults(cat_filter($listing_sql), $max_results, 'p.products_id', 'page');
> 
> Instead of:
> 
> $listing_split = new splitPageResults(cat_filter($listing_sql), MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
> 
> (But both ways don't work)
> )
> 
> 
> 
> Is there a simple mistake I'm overlooking? Does anybody have a clue what's obvious I did wrong?
> 
> Thanks in advance.
You have to create a file includes/config_sites/antiekbeslag.nl_config.php
This file has to contain all the different setting for your site;
For exemple, you could have:
```php
$template_dir = 'classic'; //Choose your template for this site
define('SITE_NAME','medea'); //Specify the name of your site

define('ENABLE_SSL', 'false'); //change some random config for exemple, here, remove the SLL for this site...

Hope it helps !

23 Aug 2007, 3:26 PM
#212
tieske avatar

tieske

New Zenner

Join Date:
Mar 2006
Posts:
23
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Thank You Gerome, and many thanks for this Mod.

It is working fine for two sites now (live site https://www.interieurbeslag.nl and test site https://www.beslagwinkel.nl) except some little issues.

As discussed earlier:

Gerome:

when you open a product from the admin section, the first line is:
"Product Master Category"
It should usually be the Category where the product is. If it is "0", then it won't show with the caqtegory filter of Multisite. You can have such problems when using Easy Populate...

If it doesn't work, could you send me a link of your test shop in private ? I will try to have a look and see what doesn't work correctly...

Does anybody know if there is a way to change the "master catagorie ID" to the "proper catagorie ID" without changing a few hundred products manually in the database?

And is there a solution for the future so I can use easy populate if necessary?

For now I disactivated the cat_filter forthe live site (great define improvement).

Thanks in davance

23 Aug 2007, 3:58 PM
#213
gerome avatar

gerome

Zen Follower

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

Re: MultiSite Module Support Thread

Tieske:

Thank You Gerome, and many thanks for this Mod.

It is working fine for two sites now (live site www.interieurbeslag.nl and test site www.beslagwinkel.nl) except some little issues.

As discussed earlier:

Does anybody know if there is a way to change the "master catagorie ID" to the "proper catagorie ID" without changing a few hundred products manually in the database?

And is there a solution for the future so I can use easy populate if necessary?

For now I disactivated the cat_filter forthe live site (great define improvement).

Thanks in davance
I added this code at the really bottom of easypopulate.php
So everytime I use this easypopulate, set the master_categories_id to the new products.

<?php
  $sql = "SELECT products_id FROM " . TABLE_PRODUCTS . " where master_categories_id ='0'";
  $check_products = $db->Execute($sql);
  while (!$check_products->EOF) {
    $sql = "SELECT products_id, categories_id FROM " . TABLE_PRODUCTS_TO_CATEGORIES . "
    WHERE products_id='" . $check_products->fields['products_id'] . "' LIMIT 1";
    $check_category = $db->Execute($sql);
    $sql = "UPDATE " . TABLE_PRODUCTS . " SET master_categories_id='" . $check_category->fields['categories_id'] . "'
    WHERE products_id='" . $check_products->fields['products_id'] . "'";
    $db->Execute($sql);
    $check_products->MoveNext();
  }
?>

I think that I could maybe add that to the Multisite admin section, however, it is even simpler to add that in easypopulate.php, so you don't bother about that anymore ...

23 Aug 2007, 6:57 PM
#214
jvoce avatar

jvoce

New Zenner

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

Re: MultiSite Module Support Thread

Is it possible to have the site_links to work outside of the sidebox? I'd like to incorporate them into a page in the main body of the site.

23 Aug 2007, 9:54 PM
#215
tieske avatar

tieske

New Zenner

Join Date:
Mar 2006
Posts:
23
Plugin Contributions:
0

Re: MultiSite Module Support Thread

To JVOCE:

jvoce:

Is it possible to have the site_links to work outside of the sidebox? I'd like to incorporate them into a page in the main body of the site.

I use the "single sidebox" contribution to implement the sidebox in the content (in my case, the newsscroller on the newspage). But can't find it right now.

To Gerome:

Thanks for the EP script to avoid "Master catagory ID = 0" in the future.

The current products I changed in the database manually since it is was a live shop. But then again... it works.

27 Aug 2007, 12:42 PM
#216
jvoce avatar

jvoce

New Zenner

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

Re: MultiSite Module Support Thread

Okay, so far I have this code written into the script, but it's obviously not completely working as I'm assuming that I either have it typed wrong, or the program doesn't understand what I'm asking it to do. Please give me some pointers.

<a href=http://store1.salvationarmy.ca . '$session'>Online Store</a>

I need the ability to place the site_link with zenid not only into the main section of a page, but I'll also need it to be placed in the code for the dropdown menu mod.

With the MultiSite Module I've set it up with different customer types, with two different levels of customers, some with access to more products. What I'm trying to do now is force everyone to login via the more secure login screen, and then be re-directed after that to the appropriate page. In essence I'm creating the illusion of two different levels of customers on one site. Something Zen is not yet able to do, but this is getting, REALLY, REALLY close, and I'd hate to see this pass by. It's quite important to our organization that only people with the right authority can buy certain products.

30 Aug 2007, 5:10 PM
#217
sputnikinternet avatar

sputnikinternet

New Zenner

Join Date:
Aug 2007
Posts:
2
Plugin Contributions:
0

Re: MultiSite Module Support Thread

we are developing this site;

www.exedy.sputcom2.co.uk

and have implemented MultiSite at

www.exedysports.sputcom2.co.uk

Eventually, the client cannot have a subdomain, so we would like the sports section to be accessed via

www.exedy.sputcom2.co.uk/sports - same domain name

As they only have one hosted account, we cannot use a htaccess redirect from a second domain name.

Is there a way we can ammend MultiSite Module to read the URL looking for /sports at the end to implement the redirect?

31 Aug 2007, 10:21 AM
#218
tieske avatar

tieske

New Zenner

Join Date:
Mar 2006
Posts:
23
Plugin Contributions:
0

Re: MultiSite Module Support Thread

My second site within the Multisite module contains only new catagories but most of the products are linked duplicates from the first site. Now only new generated products will display at the second site.

I want to link the products (instead of a copy) since otherwise info (price, stock) have to be changed several times for the same product... more work and more risk of making mistakes.

Couldn't find any post on this issue; is there somethink I'm missing and is there a solution?

Thanks in advance.

31 Aug 2007, 10:46 AM
#219
sputnikinternet avatar

sputnikinternet

New Zenner

Join Date:
Aug 2007
Posts:
2
Plugin Contributions:
0

Re: MultiSite Module Support Thread

I worked it out with a bit of a hack.

Here is my new code for sites_switch.php
For pages that dont have the right cPath but need the other template, i manually added ?my_page=sports to the URL in the navigation.

<?php $default_server_name = $_SERVER['HTTP_HOST']; // $config_file = $default_server_name.'_config.php'; $my_length = strlen($cPath); $my_remove = ($my_length - 2); $my_remove = 0 - $my_remove; if ($my_remove !=0){ $my_first_chars = substr($cPath, 0, $my_remove); } else {$my_first_chars = $cPath;} if ($cPath == 4 || $my_page == "sports"){ $config_file = 'www.exedysports.sputcom2.co.uk_config.php'; } else {$config_file = 'www.exedy.sputcom2.co.uk_config.php';} if(file_exists("includes/config_sites/$config_file")) { include("includes/config_sites/$config_file"); } else { echo "the domain $config_file does not exist."; exit; } //Name of the site that is written in the categories define('SITE_NAME',$config_file); //The order for this site will be seen for ORDER_SITE from the admin section define('ORDER_SITE',SITE_NAME); define('HTTP_SERVER', "http://$default_server_name"); define('HTTPS_SERVER', "https://$default_server_name"); ?>
31 Aug 2007, 11:15 AM
#220
gerome avatar

gerome

Zen Follower

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

Re: MultiSite Module Support Thread

sputnikinternet:

I worked it out with a bit of a hack.

Here is my new code for sites_switch.php
For pages that dont have the right cPath but need the other template, i manually added ?my_page=sports to the URL in the navigation.

<?php $default_server_name = $_SERVER['HTTP_HOST']; // $config_file = $default_server_name.'_config.php'; $my_length = strlen($cPath); $my_remove = ($my_length - 2); $my_remove = 0 - $my_remove; if ($my_remove !=0){ $my_first_chars = substr($cPath, 0, $my_remove); } else {$my_first_chars = $cPath;} if ($cPath == 4 || $my_page == "sports"){ $config_file = 'www.exedysports.sputcom2.co.uk_config.php'; } else {$config_file = 'www.exedy.sputcom2.co.uk_config.php';} if(file_exists("includes/config_sites/$config_file")) { include("includes/config_sites/$config_file"); } else { echo "the domain $config_file does not exist."; exit; } //Name of the site that is written in the categories define('SITE_NAME',$config_file); //The order for this site will be seen for ORDER_SITE from the admin section define('ORDER_SITE',SITE_NAME); define('HTTP_SERVER', "http://$default_server_name"); define('HTTPS_SERVER', "https://$default_server_name"); ?>

you should do something like that instead:
file includes/config_sites/www.exedy.sputcom2.co.uk_config.php

$location = explode('/',$_SERVER['REQUEST_URI']);
if($location[1]=='sports') { //config for the site in the folder /sports/
 include('includes/config_sites/www.exedy.sputcom2.co.uk_sports_config.php');
} else {
  //write here the config for the site in the root folder...
}

By doing that, you don't have to change the code of the site_switch.php
(and you don't need my_page=sports...)

Hope this helps !!

Gerome.