Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: 1 [2] 3

Author Topic: Multiple installations using one sNews engine and one database.  (Read 20310 times)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Multiple installations using one sNews engine and one database.
« Reply #15 on: July 06, 2007, 08:21:28 pm »

Quote from: agentsmith
So, [stupid question #1] you exclude users in each 'prefix_' subset, right? (does that work?)
Yes... if all sub-sites are using the same users table, you would not need a users table for each subsite... example table structure for an MU site:
Quote
(tables for root installation)
- articles, categories, comments, settings, users.
(tables for sub-site 1)
- sub1_articles, sub1_categories, sub1_comments, sub1_settings.
(table for sub-site 2)
- sub2_articles, sub2_categories, sub2_comments, sub2_settings.
Initial Testing:
Using Joost's structure, I have a primary (root) site with one sub-site in the root. I created the database with the 5 tables (including the users table for Bob's MU-pack) plus the same set of tables prefixed for the sub-site. While I intended to run them all on the same users table... I wanted to see if the sub-site would allow users and logins completely independent of the root install.
Good Result. It works - the sub-site is using its own users table and running as a standalone. :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Multiple installations using one sNews engine and one database.
« Reply #16 on: July 06, 2007, 08:25:17 pm »

Quote from: mo
@agent:  bobster's MU  ?,  is this the same as rui's MU ?
No, they aren't the same. ruis MU is available for public access, bobsters ... dunno, haven't noticed it published as separate MOD code, still WIP?
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Multiple installations using one sNews engine and one database.
« Reply #17 on: July 06, 2007, 08:31:52 pm »

This one probably is best answer IMHO to one regularly resurfacing question - how to create pages with truly different layout :)
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Multiple installations using one sNews engine and one database.
« Reply #18 on: July 06, 2007, 08:39:01 pm »

Quote from: codetwist
This one probably is best answer IMHO to one regularly resurfacing question - how to create pages with truly different layout :)
You're right... it does appear to answer it simply.
@ Bob - looks like the idea of "modularity" is coming to fruition...  :cool:
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Multiple installations using one sNews engine and one database.
« Reply #19 on: July 07, 2007, 02:59:19 am »

@key's: Stupid Question #2 -- How do you use ".gl('blah_tables').'" in this scenario:
Quote from: ~line 2498
function retrieve($column, $table, $field, $value) {
   $query = "SELECT $column FROM ".db('prefix')."$table
ILeave it as it is?
There are a couple of others like that one, for instance in the RSS block. I think I've worked around those though... Or maybe I'm not grasping the concept, what do I know...
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Multiple installations using one sNews engine and one database.
« Reply #20 on: July 07, 2007, 04:03:55 am »

@ Agent...
You can leave that one as it is...
Quote
$query = "SELECT $column FROM ".db('prefix')."$table ...
The $table variable is already defined elsewhere and only applies when you make use of the prefix variable up in the $db variables array. When using the $gl variables array to replace table names... the prefix variable becomes redundant... since we can now define each table with a variable. In other words... the $gl variables serve the same purpose as the prefix variable did... but we can now apply them to individual tables rather than to all tables at once. (I better stop now before it gets any more confusing).

Module Structure is Born! - I don't know about the rest of you... but I beleive Joost has contributed the first major step towards modular structure for sNews. We are creating modules that stand alone and apart from the engine file and its supporting infrastructure (other under-the-hood stuff-in-the-root). And we have the option of using any number of module-specific tables mixed with any of the root (main site's) tables... (replacing table-names with variable values in the engine file)... and module-specific templates as well. Well done Joost... I think this turned out to be a very productive day... at least for me. :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Multiple installations using one sNews engine and one database.
« Reply #21 on: July 07, 2007, 04:13:27 am »

Ok, so these are some quick reflections after having searched and destroyed the whole snews.php, replacing db('prefix') with ".gl('xxxxxx_table')." as per keyrocks' description - and of course creating some subdirectories with all necessary parts (db tables, prefixed db data, index.php, config.php). Note that this is based on my specific dev site, and also that I'm sure to have fudged some basic things in the process. YMMV, as they say. All that aside, here's what happens for me. The concept is to use a single snews.php, a single stylesheet and (I hoped) a single users table.

1) Setup is not a problem. Root site (unprefixed) works as expected, pages works as they should. Subcategory setup also works as expected, just remember to search your snews.php for hardcoded image or script URLs. So far so good. Single snews.php: check. Single stylesheet: check.

2) I am logged in as Admin in root. When I go to my subdir, I'm no longer logged in. So I log in again as Admin. In Bakercad's MU which isn't publicly released yet, Admin has s-user strength, he/she/it can do anything. Not so in subdir mode, which isn't a fault in the mod itself, I think, just an effect of this particular combo. For those who might want to know about it. Anyway, it seems that having one single user table works, but not the way I had imagined, so I'm going to try with separate user tables for each subdir.

3) The big strangeness, which I guess could be caused by my built-in denseness, but I'm not sure. In subdir (for example: root/issues/) create a new category, create an article, go home, then click the category link in the cat menu: 404. Go to Archive, click the article's link: 404. Look in the cat menu list: the categories created on the root are visible here; click one of them (news): 404. The first two 404's are irrational: an article created in a category on the subdir I'm standing in should not throw a 404. Which is where I'm thinking, "ok, did something wrong".

Conclusion: get some sleep, reset snews.php and try one of the other solutions offered above to see if I can get it to work as I want it to work.

The basics of the mod works fine, it's just a matter of keeping within its perimeter I guess. Not wander off too far out.

Yeah. Sleep.
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Multiple installations using one sNews engine and one database.
« Reply #22 on: July 07, 2007, 07:44:41 am »

Of course it will throw 404 ;) Unless You have modded .htaccess and probably snews_startup() as well to account for these modules/subsites in folders.
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Multiple installations using one sNews engine and one database.
« Reply #23 on: July 07, 2007, 01:59:58 pm »

That was done in 1). I may be seriously dense when it comes to scripting. But not that dense.
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Multiple installations using one sNews engine and one database.
« Reply #24 on: July 08, 2007, 11:00:44 pm »

Quote from: agentsmith
That was done in 1). I may be seriously dense when it comes to scripting. But not that dense.
Ok, my point of view follows. If following assumptions are correct:
   a) there is category created in subsite
   b) link for calling that category contains valid href
   c) using that valid link throws 404
then most probable cause might be setup (aka .htaccess) and initialization problems (aka snews_startup). I don't think that default setup of those two really accounted for nested snews configuration.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Multiple installations using one sNews engine and one database.
« Reply #25 on: July 08, 2007, 11:04:05 pm »

---------------------------------------------
In function breadcrumbs:
---------------------------------------------
When a site visitor is on the home page of a given sub-site module, it is desirable to replace the "Home" link in the breadcrumbs links line with the actual name of the module. This can be done by replacing the l('home') language variable value... in function breadcrumbs()... with s('website_title');. This will change the "home" link in the breadcrumbs link string to display the Website Title defined in the Admin's Settings >> Settings panel. As an example, if you set the Website Title as "Cool Cars"... the "Home" link in the breadcrumbs line gets replaced with "Cool Cars"... telling the site visitor he/she is in the Cool Cars module.

Making the Mod:
In function breadcrumbs()... locate this string:
Quote
echo (!empty($categorySEF) || $categorySEF == $home || !empty($articleSEF)) ?
$link.'"title="'.l('home').'">'.l('home').'' : l('home');
... and replace itwith:
Quote
echo (!empty($categorySEF) || $categorySEF == $home || !empty($articleSEF)) ?
$link.'"title="'.s('website_title').'">'.s('website_title').'' : s('website_title');
Update:
So far it is NOT working... needs more work. As change occur, I will note them here in this post.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Multiple installations using one sNews engine and one database.
« Reply #26 on: July 08, 2007, 11:22:53 pm »

Quote from: agentsmith
2) I am logged in as Admin in root. When I go to my subdir, I'm no longer logged in. So I log in again as Admin. In Bakercad's MU which isn't publicly released yet, Admin has s-user strength, he/she/it can do anything. Not so in subdir mode, which isn't a fault in the mod itself, I think, just an effect of this particular combo. For those who might want to know about it. Anyway, it seems that having one single user table works, but not the way I had imagined, so I'm going to try with separate user tables for each subdir.
Per chance, function token() used for session status checking isn't  using website parameter as one of building  blocks? Might have different values for root where login was done and for subsite where it's checked later. Same story and possible solutions as for settings, etc. here IMHO.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Multiple installations using one sNews engine and one database.
« Reply #27 on: July 08, 2007, 11:55:11 pm »

Hmmm... so I am finally getting to add some categories and articles to my first sub-site module and... although they are all being saved to the correct dbase tables... clicking on any article or category link always displays a BLANK white page... pretty much the same as Agentsmith was experiencing in getting the four-0-four error message... more work to do... (aw shucks!)  :/

NOTE: I returned my function breadcrumbs() to normal for now. Both the root install and sub-site module are using their own table-sets separate from each other (10 tables in the dbase). I am not working with a single users table at this point. The blank pages display whether I am logged in or not.

UPDATE:
I've run out of time on my sub-sites project and I hate to say it... but I am coming to the conclusion that this method of running sub-sites as modules will require a lot of changes in the engine file... as Codetwist is suggesting. I need a working demo for this coming Thursday and will revert to using separate engine fines in each install... but still use the same database... since it was working for me earlier.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Joost

  • Guest
Multiple installations using one sNews engine and one database.
« Reply #28 on: July 09, 2007, 09:15:17 am »

Quote from: agentsmith
2) I am logged in as Admin in root. When I go to my subdir, I'm no longer logged in.
More or less expected.
I did a little test using a one admin snews.php and this function token():
Quote
$token = '4'
After log into office (root), I had to log into Britney (a dirty job, but someone has got to do it).
Then I went back to the office admin, without problem. After changing function token(), I was logged out.

So it seems a session can contain several tokens with different values or several tokens with the same value. Of course all tokens are destroyed when logging out.
I hope this little exercise clarifies the limitations of this approach, without additional modding.
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Multiple installations using one sNews engine and one database.
« Reply #29 on: July 09, 2007, 10:38:41 am »

@ Joost : Limitations, heh ;) You weren't  really hoping to avoid modifications at all were You? After all, there was changes if small already in Your original example - function with configuration variables had to be changed/comented out/ whatever. I think, this one requires surprisingly few modifications to have a huge benefits for setting up complex configurations. Need a little brewing ... errr ... thinking on implementation aspects. Should beat anything here around on benefits/modifications needed ratio IMHO. So, potential is good and 'forget' the limitations - they are for overcoming :)
Logged
Pages: 1 [2] 3