Welcome Guest, Not a member yet? Register   Sign In
wrapper page
#1

[eluser]ytjohn[/eluser]
Hello, I'm looking for some coding advice. I'm building an internal reference site for our organization.

While we will be setting up a search engine and all-around integration, for one the part I am working on a sort of website wrapper. Essentially, I have a mirror of LDP's content in my "assets" directory (which is not affected by .htaccess redirects). So, url wise, it's /assets/ldp/filename.html. Directory wise, it's /home/username/public_html/assets/ldp/filename.html.

The idea is that someone goes to http://www.example.com/ldp/guides.html, it will redirect to /index.php/$1, and routes.php will translate it as follows:

$route['ldp/:any'] = "ldp/index/pagename/$1"

Now, for flat-files, I can work out how to pull that in by grabbing the value of pagename and using file_get_contents. However, I run into the following issues:

1) multiple directory levels: a url like "ldp/authors/inprogress.html#inprogress" would get broken up in this scenario. Can I get everything after ldp/ to be put into one variable? Or do I have to do a regex to convert "/" into / (while avoiding href "/" characters)?

2) Images are stored in /assets/ldp/images. Since the files are flat, the webbrowser will interpret the url as "/ldp/images/guides.jpg". Other than setting up exceptions for .jpg/.gif/.psd/.other items, is there an easy way to detect these files and just display the contents. As I write this, I suppose I could just display the contents (no wrapper) for any file not ending in .html.

I had also considered placing the files into a views subdirectory and having the view include the file, bug I believe that it would be the same issues either way.
#2

[eluser]Teks[/eluser]
I am not certain I understand what you are trying to achieve - your post was not clear and descriptive enough for my little brain. Nevertheless, here are a couple of pointers, that may be of use:

[quote author="ytjohn" date="1227545654"]
[...]
1) multiple directory levels: a url like "ldp/authors/inprogress.html#inprogress" would get broken up in this scenario. Can I get everything after ldp/ to be put into one variable? Or do I have to do a regex to convert "/" into / (while avoiding href "/" characters)?
[/quote]

Have a look at the documentation for the URI Class. The following functions may be able to help you:

* $this->uri->total_segments(), or $this->uri->total_rsegments()
* $this->uri->segment_array(), or $this->uri->rsegment_array()

Quote:2) Images are stored in /assets/ldp/images. Since the files are flat, the webbrowser will interpret the url as "/ldp/images/guides.jpg". Other than setting up exceptions for .jpg/.gif/.psd/.other items, is there an easy way to detect these files and just display the contents. As I write this, I suppose I could just display the contents (no wrapper) for any file not ending in .html.

I had also considered placing the files into a views subdirectory and having the view include the file, bug I believe that it would be the same issues either way.

Again, I am not certain I understand what you are trying to do here. I do understand that you have a directory full of image files, which can be JPGs, GIFs, PSDs or in some other format. But what I don't understand is what you want to do with these files. Do you want to:

a) Display information about these files - ie., file name, type, size, etc.?
To get file information, you may wish to have a look at the documentation for the File Helper.

b) Provide a link so the user can download the file?
To automatically, and dynamically create links to your images, investigate the anchor() function of the URI Helper.

c) Allow the files to be conditionally displayed inside dynamically generated html pages?
You can serve the image files directly from the directory they are in, but, if necessary, you can also use a sub-view/view partial/nested view/view snippet, which builds the appropriate html element based on the type of file passed to it. So, for instance, if you pass a JPG as an argument, your sub-view will generate an img element, which will display on the page. If you pass it a PSD, it will build an information table instead, with a link for the user to download the image.

I'm not sure that this is what you require, but in any case, I hope it helps!




Theme © iAndrew 2016 - Forum software by © MyBB