|
|||
|
Hi all,
I've read some stuff on modules however I'm new to Zend Framework and MVC, and just don't seem to be understanding it with regards to normal websites. Is there a way to have a default controller that handles all http requests? I'm creating a very simply CMS that allows a user to add/edit/delete pages (and child pages). I want a module setup to handle the admin area (mysite.com/admin), and within this admin area I want a full application for adding content. This seems to be the easy part. The part I don't understand is how to make every other type of request (i.e. mysite.com/abc, mysite.com/123, mysite.com/abc/def/ghi, etc) use a default controller and view script. Other than the admin area, every page should work exactly the same; the only difference being the file it pulls content from, which will depend on the URL being requested. Advice would be great. |
|
|||
|
I could be wrong but what it sounds like is you want a standard 'template' for every page?
If so, I would suggest checking out the Zend Framework Webinars In particular there is one called 'Zend_Layout and Zend_View Enhancements'. This will show you how to use the new ZF 1.5 Layouts to have a standard layout with view content being inserted in it. Also, check out: PHP VIDEO TUTORIALS FOR WEB DESIGNERS. There are some good screencasts by Jon Lebensold. I believe one touches on the new Layout features. It's a good series to go through. |
|
|||
|
Thank you for the reply Toppy, however I believe you misunderstood. I actually have viewed the new layout webinar and do plan on using that approach, however my question was related to the framework files (mostly controllers), not just the layout. For instance, take the following URLs:
mysite.com/index mysite.com/about_us mysite.com/services/ mysite.com/services/service1 mysite.com/services/service1/features mysite.com/services/service2 mysite.com/services/service1/pricing My understanding of Zend Framework and MVC is that I'd need a controller for index, about_us, and services. In addition, I'd need view scripts for service1 and service2. Anything after the view sript is supposed to be variable/value pairs, so I don't even know how that would work (third, fourth, fifth level directories), but it's besides the point. The problem is that with a CMS I have no idea what pages the user will create, and how many child pages each page will have. Let's say a user wants to create two new pages, one being mysite.com/contact_us, and the other being mysite.com/services/service3. From a coding standpoint, do I need to dynamically create a new controller and view script for the contact_us page, and dynamically create a new view script in the already created services view script area for service3? I plan on storing the actual page content in a database or XML file, therefore the view scripts won't even contain the main content, so it would be nice if I can have one controller and view script handle everything. BJM |
|
|||
|
hmmm .. Thank you for the feedback, unfortunately I was hoping for a much slicker method. Using parameter/value pairs (mysite.com/cmscontroller/id/1234) is good for viewing things like news items or article items, however I don't like that approach for actual page names. In my experience clients can be picky about their URLs, especially when they advertise them. I think people may complain if I tell them to print "mysite.com/services/id/1234" on a brochure instead of "mysite.com/services/service1/features/".
In addition, this wouldn't resolve the problem of a site with 20 or 50 (although that may be unrealistic) "top level" pages (mysite.com/a, mysite.com/b, mysite.com/c, mysite.com/d, etc). It seems odd that I would be forced to create a different controller for all of these pages even though the logic for them will be the exact same. Either I'm misunderstanding (which I admit is probably the case), or MVC is better left to web applications, not basic websites with tonnes of pages. Separating content from process is great, but now I'm stuck with choosing between unfriendly URL's, or having redundant controller files that all do the same thing. ![]() |
|
|||
|
If anyone is interested, I've been able to solve the issue using routes:
PHP Code:
. Thanks for the replies. |
|
|||
|
I'm looking at doing a similar thing and was thinking of setting up a StaticController which would hold all the static pages within /app/views/scripts/static/.
I was then going to setup static routes for each one, you how ever have done it for all URLs how did you go about flagging Error pages?! |
![]() |
| Thread Tools | |
| Display Modes | |
|
|