Welcome Guest, Not a member yet? Register   Sign In
Problem setting up multi-app
#1

[eluser]vecima[/eluser]
Hi, I've been using CI for a while now, but I've run into a problem.

I read on the user guide that you can relocate/rename the application folder.
I also read that you can manage multiple apps.
(I read these things here: user guide - managing apps)

What I'm trying to do is both. I have a fairly static main page, and I want
to add a more dynamic community oriented site.

Here is my directory setup: (omitting folders for css, js, images, etc)

-------------------------------------------------------------------------------------
MyDomain.com/

- index.php ( $system_folder = "system"; $application_folder = "application1"; )

- application1/
----- config/
----- controllers/
----- models/
----- views/
----- etc/

- application2/
----- index.php ( $system_folder = "../system"; $application_folder = "../application2"; )
----- config/
----- controllers/
--------- main.php
--------- blog.php
----- models/
----- views/
--------- welcome_message.php
--------- blog_view.php
----- etc/

- system/
-------------------------------------------------------------------------------------

Everything works fine with applicaiton1 (it's a simple relocate/rename of the "applicaiton" folder). with application2, I access it by http://MyDomain.com/application2 and it loads the default controller, and loads the view specified by the default controller's index method. when I try http://MyDomain.com/application2/blog I get a 404 error. I've tried with the Blog controller (as shown above) and with just a blog() method in the Main controller. I get a 404 either way.

what do I need to change? Ideally I would like 2 application folders located outside the system folder (it's just way too deep to edit views and controllers down that whole path). I also don't want to put folders for each application under each "views" and "controllers" folder... that would get confusing.

what do I do?
#2

[eluser]vecima[/eluser]
The user guide also says this:

Quote:For example, let's say you want to create two applications, "foo" and "bar". You will structure your application folder like this:

system/application/foo/
system/application/foo/config/
system/application/foo/controllers/
system/application/foo/errors/
system/application/foo/libraries/
system/application/foo/models/
system/application/foo/views/
system/application/bar/
system/application/bar/config/
system/application/bar/controllers/
system/application/bar/errors/
system/application/bar/libraries/
system/application/bar/models/
system/application/bar/views/

To select a particular application for use requires that you open your main index.php file and set the $application_folder variable. For example, to select the "foo" application for use you would do this:

$application_folder = "application/foo";

this makes sense, but, if you set the application_folder to "application/foo" then how do you access the bar application? it says you need an index.php for each application, but where do they go? also, I've removed /index.php/ from the uri, specifically because I don't want it there. does this mean that i would need /application1.php/ or /applicaiton2.php/ in my uri in order to have multi-apps?
#3

[eluser]John_Betong[/eluser]
 
The way I tackle this is to call a http://localhost/_menu.php file that sets S_SESSION['_MENU_']

http://localhost/index.php
Code:
$application_folder = isset($_SESSION['_MENU_']) ? $_SESSION['_MENU_'] : 'ci_jokes';
 
Here is the original thread:

http://ellislab.com/forums/viewthread/59270/

 
 
 
#4

[eluser]vecima[/eluser]
I noticed that you're setting that session variable with a $_GET variable... so how do i call the code from your other thread? it seems a little weird to handle it with forms.

I'll give this solution a shot though, if i can figure it out.
#5

[eluser]John_Betong[/eluser]
[quote author="vecima" date="1250578545"]I noticed that you're setting that session variable with a $_GET variable... so how do i call the code from your other thread? it seems a little weird to handle it with forms.

I'll give this solution a shot though, if i can figure it out.[/quote]
 
With my LocalHost CodeIgniter setup:

1. All CodeIgniter applications use a common ci_system. (easy to upgrade and switch).
2. I have numerous application all prefixed with ci_
3. All localhost CodeIgniter applications are called from http:/localhost/_menu.php

In order to be able to:
a) set $_SESSION['_MENU']
b) _menu.php calls with _menu.php?application='my_selection'
c) sets $_SESSION[_MENU'] to $_GET['application']
d) redirects to index.php.
e) index.php sets $application_folder to $_SESSION['_MENU'].

My _menu.php can be seen online at http://johns-jokes.com/_menu.php. Please note that the only valid application is ci_jokes because all other options are on my locahost.
 
I am curious to know how other people handle multiple applications.
 
 
 




Theme © iAndrew 2016 - Forum software by © MyBB