Welcome Guest, Not a member yet? Register   Sign In
Newbie: Folder Structure - is this possible ? (boolean answer may sufice) :-)
#1

[eluser]MEM[/eluser]
Hello all,

I have read some threads here and there about organizing folders on a site with admin or backend functionalities. However, I'm unable to find a thread that satisfies this scenario.

Many hosts out there, have a 'private' folder accessible only by FTP, Local, or Script. (no browser access is allowed). I think this is a very nice feature, and that It would be nice to explore. So I do ask:

could something like this be possible?

Quote:/www
/www ( default - http://www.mysite.com )
- index.php (the router file)
/admin ( subdomain - http://admin.mysite.com )
- index.php (the router file)
/blabla ( another subdomain access folder )
/private
/system
/application
/config
/controllers
/admin
- home.php
- products.php
- categories.php
- home.php
- institutional.php
- products.php
- categories.php
/errors
/helpers
/hooks
/language
/libraries
/models
/views
/admin
- home_view.php
- product_view.php
- institutional_view.php
- categories_view.php
- home_view.php
- product_view.php
- institutional_view.php
- categories_view.php
/templates*
/assets*


My assumptions (that could be wrong of course):
-> All calls from the browser will necessarily pass by the router, after this,
the router calls the right controller based on the URL provided, and finally,
the controller deals with choosing the model and the view to be used.


Is this feasible?

*I've seen some structures provided by other users, that put templates and assets in the public_html (here www) folder. Why is this? Shouldn't they only be accessible by script ?




Thanks a lot in advance,
Márcio
#2

[eluser]Phil Sturgeon[/eluser]
Close.

Having index.php inside the public directory is correct, but you also need to have your assets there too.

PHP can include private files, but you cannot reference images or CSS files within the private folder. If you could see an image in the private folder then it would defeat the entire purpose of it being a private folder! :-)
#3

[eluser]MEM[/eluser]
Thanks Phil.

Ok, if I get you right, we don't do that, because the image path will be available for anyone to see trought a simple "View Source", however an include path is not so acessible, hence, despite the fact that we can include private files, we can't give img src and css info that points to our private folder ?


What about the templates folder?


Thanks again,
Márcio
#4

[eluser]Phil Sturgeon[/eluser]
Are the templates just PHP files or does it contain images? Remember that anything you include via HTML (src=, href=, etc) is EXACTLY the same to the server as you loading it via the URL bar of your browser.
#5

[eluser]MEM[/eluser]
I didn't know that. I haven't tested. So even if I was putting the assets folder inside the private folder, I would get nothing, since, the private folder permissions don't allow that.

I'm sure my template files will have some js or css later on, so I will put themes folder on public html or www folder as well.

Quest complete. Now I'm starting to understand why everybody else was having thoses folders on public places. Big Grin I will still need a way to avoid hotlinking. But to not bother you any more, I will reserve that for a later topic.

Thanks a lot for the replies.
Márcio
#6

[eluser]MEM[/eluser]
I'm sorry for yet another post on this, but I'm really not getting there yet...

According to what as being said, since the header and footer will have paths to images, and probably to js code, they should stay out of the private folder and, also, be placed on the public part.

But, if we put the template folder outside the private folder, hence, outside the CI application folder, how can we call that template using the load->view ?

I have been here:
http://ellislab.com/codeigniter/user-gui...oader.html
http://ellislab.com/codeigniter/user-gui...views.html

It's written that we can load a view that it's on a subfolder like this:
Code:
load->view('mysubfolder/myview')

But, in this case, I need to load the template view from a controller. The controller is on the private/application/controller folder. The template, however, is on public/www/template/ folder.

So, doing something like
Code:
load->view('templatefolder/myview')
will not work I suppose.

I have tried a full path as parameter, and it hasn't work either.

Any help?
Márcio
#7

[eluser]MEM[/eluser]
Update:
No it's not possible.

But we can try to do it:

1)Like bargainph suggested here:
http://ellislab.com/forums/viewthread/121174/#600423
On the + side: very easy.
On the - side very tricky, and will not behave well with future upgrades.

(we can create a class to change the property instead of change it directly I know but, if you are like me, then you will see that CI is already to big (on a newbiew prespective), and extending it is putting more complicate variables on this, already big, framework.


2) or like jedd here:
http://ellislab.com/forums/viewthread/111088/#560977
+ allow updates
- complicated (if you are newbie like me, maybe making a MY_Controller isn't the easy of things to do).


3) Or, doing like suzkaw says here:
http://ellislab.com/forums/viewthread/111048/#561095

However, on this third method I do have some questions:
Where should we put the view files that are not templates?
Where should we put the header.php and footer.php?

As before, I believe they should be outside the private folder for security reasons.
But this implies that we should proceed with the sames changes for our views folder as well, and create or views folder, on the public side of things. No?


Regards,
Márcio
#8

[eluser]jedd[/eluser]
In defence of extending the controller approach ...

Several things become much easier once you've got that in play. It's arguable (and argued a bit around here) that it should be shipped as default.

Setting up the basic skeleton is a six-line file that you create: application/libraries/MY_Controller.php and is [url="http://localhost/devel/ci_user_guide/general/core_classes.html"]nicely documented in the user guide[/url]. Specifically creating that file with this contents will work (it won't do anything different, of course, until you write your own code) :
Code:
<?php
class MY_Controller  extends  Controller  {
    function MY_Controller ()  {
        parent::Controller();
        }
    }

Using it requires two words to be changed in each of your controllers (nicely documented as per above - but simply what you extend, and what your parent is, changes to from Controller to MY_Controller).
#9

[eluser]MEM[/eluser]
Thanks for the reply jedd.

Setting up a skeleton is, as you say, a matter of adding six lines of code.
The hard part isn't understand how to do that, like it says here:
http://ellislab.com/codeigniter/user-gui...asses.html (your previous link points to localhost).
Or in this thread: http://ellislab.com/forums/viewthread/125465/#620707


The hard part is to build a view system based on controller extension method. :-)

I know, I know, a LOT of posts have been made of that. But believe me, a LOT MORE have been written, telling that there is a lot of posts about the subject. :-)

I'm trying to apply my first template application with CI, and I found the load of views on other views, much more easier then the extented controller method.
But, as you also say, and I believe you, in the future, we could grab the benefits. So why I'm not doing that?

Because, I can't find any post, any reference, on the forums, on google, on mailing lists, that explain that method on a "10.000 foot view".

My big request:

After, being on a LOT of threads, and mainly here:
http://ellislab.com/forums/viewthread/110969/P0/

I do ask - do you, or anyone else - care do drop a very nice example (or a link) on using the controller extension method WITH a directory/file structure included on that example?


Regards,
Marcio
#10

[eluser]jedd[/eluser]
[quote author="MEM" date="1251479400"]
I do ask - do you, or anyone else - care do drop a very nice example (or a link) on using the controller extension method WITH a directory/file structure included on that example?
[/quote]

I think perhaps you over-estimate the complexity of this approach. (Note that you have to write the code that does the stuff you want done, no matter what approach you adopt - hooks, autoload, core library extensions, whatever. It's just where that code gets put that changes, depending on the approach.)

There's no directory structure change required. You put a file in the libraries directory (as above) and you change your controller's preamble (as above) and that's it.

To start using the common-code features you just make methods in MY_Controller - and you then use them in your Controller.


For example a function to check if the user is currently logged in, called _authenticate_user() - in MY_Controller. And in your Controller(s) you'd have a call thus $this->_authenticate_user()

I have some code snippets at the thread you mentioned, and also on [url="http://codeigniter.com/wiki/Header_and_Footer_and_Menu_on_every_page_-_jedd/"]this wiki page[/url].




Theme © iAndrew 2016 - Forum software by © MyBB