Moderator: General Moderators
I'm about to embark on a new project that will have be a regular website. However, it will also have a mobile website, a mobile app, and a desktop application. The mobile app and desktop applications I'm thinking will likely just contain a blank file that will grab the mobile website and display it via ajax.
Here's how I'm thinking about doing this.
Design the normal website in a place like follows:
And then, the other versions will reside in respective locations:
Basically, the full version will be in the /web/ directory. The other versions will only have files specific to those versions. For example, the mobile version will definitely have a few different templates. The main page will check if there's a mobile version of a file to serve, and if not, include the web version.
So basically I'm just doing the whole thing in /web/ and only putting files that are different in the other directories and checking for it on page load.
Is this the best way to go about this? Would another way be better? What other way? Perhaps just make an API (though, then I'd have to make 4 separate versions?). Thoughts? Ideas?
Actually that suggests a sixth folder for the "framework" code. For the most part that is what runs first, it decides to invoke the code/index.php controller, then passes any data to the correct view.
- Site Administrator
- Posts: 13592
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
What you are doing sounds very complicated -- unless your various versions are completely different.
The difference will be the layout and a little bit of code here and there. I will have different layouts for the Web and mobile versions (the apps will likely use the mobile layout). So, the layout template file will likely be unique. And then, for example, push notifications for desktop and mobile app will need to be coded. The mobile push code would go in the mobile app folder and no where else.
Most pages will be identical. So say there is a profile.php. On the mobile site once the mobile layout is loaded, my code will just grab profile.php from the normal website (/web directory).
But say i wanted the mobile version of profile.php to be very different with different info.. Id make a new profile.php and place it in the mobile web directory.
In pseudo code, each directory's index.php (router) would include pages like this..
If (page exists in this folder)
Include this specific version
Include page from normal /web
This way i could easily just drop in a specific page for, let's say, the mobile Web version. Everything else would remain the same.
I was thinking of using sub domains instead of folders. That way each version could have its own document root. But I'm really not familiar with this. Good idea?
Thanks for the input both of you. It seems pretty simple but i don't want to code the whole thing for it not to work without significant recoding. I'm sorry if i haven't been clear. Perhaps in a little bit I'll post a sample directory structure and index route script.
Pseudo directory structure:
Code: Select all
/framework_code/ /psuedodirstructurehere/ /pages/ profile.php main.php anotherone.php /template/ layout.tpl /public_html/ /web/ index.php /mobileweb/ /template/ layout.tpl index.php profile.php /mobileapp/ index.php /desktopapp/ index.php
Then, for example:
/web index.php router pseudo code
Code: Select all
//request for profile.php, easy direct get include '../../framework_code/template/layout.tpl'; include '../../framework_code/pages/profile.php'; inject content from profile.php into layout.tpl display page
Code: Select all
//request for profile.php, which has a mobile specific version if (specific template file in this folder) include template/layout.tpl else include ../../framework_code/template/layout.tpl if (profile.php is in /mobileweb folder) include profile.php else include ../../framework_code/pages/profile.php inject content from profile.php into whatever template was grabbed display page
With subdomains, such as:
Each folder would be it's own document root. I think I'd be fine with doing the above even though the includes will technically come from another subdomain, right? (include ../../framework/etc.php from mobile.domain.com would still work?)
I could set the cookies to work on any of the subdomains.
Sorry for long post.
EDIT| 5000 posts!
EDIT2| Actually, in the framework code templates folder, I should split that up into subdirectories for each versions templates. That way, I can check the versions folder, include that template if it exists, otherwise include the main web template for that page. This will stop me from polluting the public directory with templates.
* NodeJS for Server
* PHP as the API
Concerns nicely separated, code becomes loosely coupled.