Iluvatar+ Posted January 19, 2012 Share Posted January 19, 2012 I am building a cms in cakephp, well i haven’t yet started but i have a good idea on what i want. I have never really used MVC before so it's quite confusing to say the least. I want a index page which can hold numerous controllers so I am able to have control over multiple tables in my database from just one view. Is this possible...? Also does anyone know of any good tutorials or help info that can guide me a bit better throughout this project? Quote Link to comment https://forums.phpfreaks.com/topic/255368-creating-a-cms/ Share on other sites More sharing options...
RussellReal Posted January 19, 2012 Share Posted January 19, 2012 I don't understand, why do you need to to use multiple controllers to have access to multiple tables, just select or update or insert into the tables, unless each of your controllers has a different useraccount or database.. and even still, its just a matter of centralizing all of that information in an include file, and include that file into each of the controller files.. Sorry if I'm a little clueless here, care to elaborate more? Quote Link to comment https://forums.phpfreaks.com/topic/255368-creating-a-cms/#findComment-1309277 Share on other sites More sharing options...
Iluvatar+ Posted January 19, 2012 Author Share Posted January 19, 2012 Sorry, I havn't explained my self correctly here. What I want is to have a main page (index) which contains more than one view. For instance, I have a admin box view and a view all posts view on the same page. Quote Link to comment https://forums.phpfreaks.com/topic/255368-creating-a-cms/#findComment-1309282 Share on other sites More sharing options...
RussellReal Posted January 19, 2012 Share Posted January 19, 2012 I've only ever done light work with CakePHP So I'm probably not the best for this question, but I did a quick google search, and came up with a result which sounds very close to what you're looking for: http://stackoverflow.com/questions/93632/cakephp-view-including-other-views however, you shouldn't need a separate view for a "view all posts" view, unless you plan to use that same view elsewhere, than I guess it makes sense to have it set up like an include, but, check the link above Sorry I wasn't enough help! Quote Link to comment https://forums.phpfreaks.com/topic/255368-creating-a-cms/#findComment-1309286 Share on other sites More sharing options...
scootstah Posted January 19, 2012 Share Posted January 19, 2012 I haven't used CakePHP, but many MVC frameworks offer partial views which you can include into your main view. I haven't looked to see if CakePHP offers this or not, but it may be worth looking into. Aside from that, in your controller you can have multiple methods all with their own view. You would use them by going to example.com/index/method1, example.com/index/method2, example.com/index/method3 etc. Maybe that is what you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/255368-creating-a-cms/#findComment-1309291 Share on other sites More sharing options...
Drongo_III Posted January 19, 2012 Share Posted January 19, 2012 Or you could store the page data (in your database) with a field for "view type" which could hold a number corresponding to a particular view layout (that's what i did when i built my own little cms to practice). So when your controller calls the model, that model will pull down the "view type" along with the page data and the controller can then use that "page type" number to render the necessary view. I am building a cms in cakephp, well i haven’t yet started but i have a good idea on what i want. I have never really used MVC before so it's quite confusing to say the least. I want a index page which can hold numerous controllers so I am able to have control over multiple tables in my database from just one view. Is this possible...? Also does anyone know of any good tutorials or help info that can guide me a bit better throughout this project? Quote Link to comment https://forums.phpfreaks.com/topic/255368-creating-a-cms/#findComment-1309301 Share on other sites More sharing options...
Iluvatar+ Posted January 19, 2012 Author Share Posted January 19, 2012 I dont quite follow you on this one. Or you could store the page data (in your database) with a field for "view type" which could hold a number corresponding to a particular view layout (that's what i did when i built my own little cms to practice). So when your controller calls the model, that model will pull down the "view type" along with the page data and the controller can then use that "page type" number to render the necessary view. Thanks for the replies... Quote Link to comment https://forums.phpfreaks.com/topic/255368-creating-a-cms/#findComment-1309307 Share on other sites More sharing options...
Drongo_III Posted January 19, 2012 Share Posted January 19, 2012 When you store you page data in the database have a column for "page type". So in your code: Page type of 1 = Two col. layout Page type of 2 = three col. layout with blog posts so when your controller talks to the model for data, the model will return the page data requested and the 'page type' number. Then when you call the view controller you can have some logic to call a different layout depending on the page type. And this way you can acheive multiple layouts. There might very well be a better way and i did it this way just because it made sense to me. But it worked ok for me. I dont quite follow you on this one. Or you could store the page data (in your database) with a field for "view type" which could hold a number corresponding to a particular view layout (that's what i did when i built my own little cms to practice). So when your controller calls the model, that model will pull down the "view type" along with the page data and the controller can then use that "page type" number to render the necessary view. Thanks for the replies... Quote Link to comment https://forums.phpfreaks.com/topic/255368-creating-a-cms/#findComment-1309314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.