Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: 1 2 [3]

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

Joost

  • Guest
Multiple installations using one sNews engine and one database.
« Reply #30 on: July 09, 2007, 10:57:37 am »

@codetwist
I was just tempering expectations :)  and trying to locate a weak spot, or challenge if you wish. I am a bit overwhelmed by all activity, to be honest.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Multiple installations using one sNews engine and one database.
« Reply #31 on: July 09, 2007, 02:51:35 pm »

New day... new approach... better result...
I took a few minutes this morning and configured another sub-site module using Bob's  default MU engine file (no other mods). Result... all the articles and categories are displaying properly. So... the problems I was experiencing with mis-directed URLs (to blank web pages) is not caused by the sNews engine core. A couple more mods are necessary when using the table-names variables array mod.

The Solution when using Table-name Variables:
This solution deals with Agentsmith's Not-so-Stupid Question #2 posed several posts back. The answer WAS.. indeed... in the Smart Retrieve function(s).

1. In the default snews.php engine file, find the // SMART RETRIEVE FUNCTION and insert a new "case-switch" block as shown in blue in the block below. This allows the $query string below it to retrieve data from whichever table it needs to.
Quote
// SMART RETRIEVE FUNCTION
# this 1.6.0 function is the same as in 1.5.31.
function retrieve($column, $table, $field, $value) {

        switch ($table) {
        case 'articles': $table = "".gl('articles_table').""; break;
        case 'categories': $table = "".gl('categories_table').""; break;
        case 'comments': $table = "".gl('comments_table').""; break;
        case 'settings': $table = "".gl('settings_table').""; break;
        case 'users': $table = "".gl('users_table').""; break;
        }

   $query = "SELECT $column FROM ".db('prefix')."$table WHERE $field = '$value'";
   $result = mysql_query($query);
   while ($r = mysql_fetch_array($result)) {$retrieve = $r[$column];}
   return $retrieve;
}
2. This applies only to "sNews Dudes" working with Bob's MU engine file. Below the above function, Bob uses a modded duplicate of it... as an array... with an additional string... in the MU engine file. We need to insert the same "case-switch" set in there too, as shown below:
Quote
## MULTI_USER
// SMART RETRIEVE FUNCTION AS ARRAY
function retrieve_array($column, $table, $field, $value) {

        switch ($table) {
        case 'articles': $table = "".gl('articles_table').""; break;
        case 'categories': $table = "".gl('categories_table').""; break;
        case 'comments': $table = "".gl('comments_table').""; break;
        case 'settings': $table = "".gl('settings_table').""; break;
        case 'users': $table = "".gl('users_table').""; break;
        }

   $query = "SELECT $column FROM ".db('prefix')."$table WHERE $field = '$value'";
   $result = mysql_query($query);
   $retrieve = array();
   while ($r = mysql_fetch_array($result)) {$retrieve[] = $r[$column];}
   return $retrieve;
}
[
3.  Scroll further down in whichever engine file you are using and locate the // CHECK IF UNIQUE function. It contains a "case-switch" set which checks the unique-ness of article and category titles. You'll notice that the default "case-switch" set is looking for them in the default-named articles and categories tables. Comment the 4 case strings out and insert the ones below... they replace the default article and category table-names with the variable values.

Code: [Select]
case 'article_seftitle': $sql = "".gl('articles_table')." WHERE seftitle = '".clean($text)."' AND id != '".$not_id."'"; break;
case 'article_title': $sql = "".gl('articles_table')." WHERE title = '".clean($text)."' AND id != '".$not_id."'"; break;
case 'category_seftitle': $sql = "".gl('categories_table')." WHERE seftitle = '".clean($text)."' AND id != '".$not_id."'"; break;
case 'category_name': $sql = "".gl('categories_table')." WHERE name = '".clean($text)."' AND id != '".$not_id."'"; break;
Summary Notes:
1. As I noted above... these changes now allow the use of the table-name variables without using the $db-prefix string... and all content now displays fine. A few hours of testing have proven the table-name variable mod to be stable. :)

2. The Breadcrumbs line mod also works fine now. The mod is made in the single engine file, and that file is shared by both the main site and the module (sub-site). This mod produces this breadcrumb for the main site... and this breadcrumb in the module (sub-site).
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

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

Another Problem that Needs a Solution
I'd hadn't gotten around to testing the nested (sub-site) module's Admin system until today and noted a serious problem. Since the sub-site's name is added to the site's URL, all of the admin panels that normally appear under the content textarea panel (when creating or editing content)... are not appearing. Obviously this is happening because the links within the snews engine's functions are not working with the sub-site folder name in the URL.

I have moved this whole topic to Programming because it is not fully functional at this time. More work is needed to somehow make the admin system switchable  to work with the various modules in the URL... using more global variables that can be set within each module's config file perhaps.
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 #33 on: July 17, 2007, 10:53:42 pm »

:lol: As a mod it was never meant to be taken to extremes, like you guys do. But have it your way. I am enjoying every bit of it.
I guess my second approach  (using one settings table) must have misled you. I took it one bridge to far. In a previous post I've tried to warn you guys, not to get over excited. You didn't get the message though. :(

Additional testing in this set up, showed unwanted behaviour. Going from (sub)site to  (sub)site, there's one session Id, but several tokens, for each site. IMHO, this is a major issue that has to be dealt with.
When treating sub sites as stand-alone sites, this behaviour is what we want; it prevents cross-site access. When treating all sub sites as one,  the token has to be transferable, like settings.
So a lot of modding has to be done.
Smaller issues on functionality: Have you thought about one image-folder to be used site wide (if needed)?

Anyway, my next mod will include an extensive list of limitations and warnings, I promise.
 :D
Logged

Keyrocks

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

Hey Joost... not to worry about giving us better or clearer warnings. I did not mind taking your idea as far as I could go... in fact I enjoy the challenge and... you never know where it will lead to. I will keep the project installed on my offline environment for ongoing consideration and exploration. :)
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 #35 on: July 18, 2007, 08:21:22 am »

@ Joost : Might be useful to refine the definition of target or split it into several independent ones ;) Otherwise, it might turn into attempt to blend few different and unrelated things into a single beast. And these ones are fun only drawing wise, not code wise :P
Logged

Joost

  • Guest
Multiple installations using one sNews engine and one database.
« Reply #36 on: July 18, 2007, 05:38:55 pm »

Quote from: codetwist
@ Joost : Might be useful to refine the definition of target or split it into several independent ones ;) Otherwise, it might turn into attempt to blend few different and unrelated things into a single beast. And these ones are fun only drawing wise, not code wise :P
That's exactly what I meant, when I said the second approach must have misled you. ;) I have another one up my sleeve, but this time I'll take it to the outer limits, before publishing. I am not saying COMING SOON!!!. I'd rather say: Maņana ;)
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Multiple installations using one sNews engine and one database.
« Reply #37 on: July 18, 2007, 09:11:57 pm »

:lol: ... that approach didn't mislead me for sure - it correctly lead me to implementation of multiple different layouts MOD for single sNews instance. Damn, I'd say that leap from 1 to many with so simple changes couldn't come from misleading, U know ;)

P.S. Errr ... this Maņana thingy ... why can't I shake a feeling that it's another incarnation of COMING SOON  :o
Logged

Joost

  • Guest
Multiple installations using one sNews engine and one database.
« Reply #38 on: July 19, 2007, 01:51:27 am »

Quote from: codetwist
P.S. Errr ... this Maņana thingy ... why can't I shake a feeling that it's another incarnation of COMING SOON  :o
:P
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Multiple installations using one sNews engine and one database.
« Reply #39 on: July 19, 2007, 05:22:24 am »

:lol:  :lol:  :lol:
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

centered

  • Guest
Multiple installations using one sNews engine and one database.
« Reply #40 on: August 16, 2007, 12:44:28 pm »

Has this developed further?

I ask because an idea hit as to include an snews image gallery using sub-sNews installation from the root.  Utilizing sNews categories it wouldn't be too hard to do something similar to a default zen-photo setup.

Sub-sNews root
--Index showing categories within the center (category image[saw a mod somewhere for this] + category description [see my new mod for that])
----category 1 utilizing mattonik's image panel, thumbnails can show the gallery set
------utilizing the WIP sub-category mod (or a different method), you can show the full article w/ comments instead of the front article w/o comments

Just an idea I just had....
Logged

Joost

  • Guest
Multiple installations using one sNews engine and one database.
« Reply #41 on: August 16, 2007, 05:14:31 pm »

You could use Codetwist's template switcher to display the category + desc function. In one template you insert
the normal in the other insert instead of .
Just a thought

What's the WIP sub-category mod? I can't find it.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Multiple installations using one sNews engine and one database.
« Reply #42 on: August 16, 2007, 05:51:43 pm »

Quote from: centered
Has this developed further?
I haven't worked on this approach since we ran into a problem (noted above)... where several modules would not deal properly with user sessions from different modules using a single engine file at the same time.

I started working on another "Modular" fork a couple days ago. This one separates the language variables into files in a langauges folder, puts templates (bakercad's mod) into a templates folder so templates can be switched from the Settings Admin Panel, and separates site-wide settings into a config.php file away from the engine file. Once I figure out how to make a language files switch, this package will allow language and template switching. It looks like this so far:

languages folder
   english.php - containing the complete language variables array,
templates folder
   default (default template folder)
      css folder
         style.css
      index.php (modified)
   temp2 folder (template folder)
      css folder
         temp2style.css
      images folder (template images only)
      index.php (modified)
.htaccess (the default file)
config.php (module-specific)
core.php (old snews.php less language and configuration settings)
index.php (opens the session, call config.php and includes the template)

----------------------------------------

Root index.php: opens the session... just as the un-modifed file did. It then includes the config.php file (the sites's settings) and chooses the currently active template from the templates folder.

Root config.php: the site settings, contained in:
1) the database variable array,
2) a new global variable array (dbase table-name variables and others) and
3) a new Files management array, containing the last 4 language variable strings (removed from the language file) so file management changes can be made more easily here. We call the engine file into action at the end of this file with an include string.

Root core.php: This contains all of the engine file functions (formerly snews.php), excluding the database, global and file management variable functions now located in config.php.
 
I don't know where it will lead to but it's working fine offline. Time will tell.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

robsayles

  • Newbie
  • *
  • Karma: 0
  • Posts: 4
Re: Multiple installations using one sNews engine and one database.
« Reply #43 on: January 23, 2009, 01:54:32 pm »

Hi Keyrocks/all

I know this is old Programming, but did anyone get a stable 1.6 multilingual working?
It seems like it was sussed as a workflow (mainly), but never finalised?

I'd be interested in any demos or helping out if I can.

ATB
Rob
Logged

Joost

  • Guest
Re: Multiple installations using one sNews engine and one database.
« Reply #44 on: January 23, 2009, 02:51:36 pm »

This is and was stable.

Additionally, you can replace

Code: [Select]
SESSION[db('website').'Logged_In']

with

Code: [Select]
SESSION[__file__]
That way, you don't have log in separately in every language section.

Note: You will still have to change passwords in each language, because the language sections do not share the same password/username table.

Logged
Pages: 1 2 [3]