When to use tables for data vs. pages
Permalink
I realize there may not be an exact answer to this, but I'd like to get people's take and understanding on this idea. Examples:
1. I have a membership database and need to work with the individual member records
2. I have a list of restaurants in the area that will each have their own page, be categorized, etc.
I could go on, but I think you get the idea. Where is that (fuzzy grey) line that where pages (and page list blocks) become ineffective and you would want to handle it the traditional way - with MySQL table records?
What would be the factors to consider? Quantity? Level of detail and/or relationship to other data?
Would love everyone's thoughts on this. More of a forest-view here.
1. I have a membership database and need to work with the individual member records
2. I have a list of restaurants in the area that will each have their own page, be categorized, etc.
I could go on, but I think you get the idea. Where is that (fuzzy grey) line that where pages (and page list blocks) become ineffective and you would want to handle it the traditional way - with MySQL table records?
What would be the factors to consider? Quantity? Level of detail and/or relationship to other data?
Would love everyone's thoughts on this. More of a forest-view here.
Mysql is used to store the data, collections (pages) are used to select save or display data from Mysql, I'm not really sure what your question is...
For me, it's all about management and maintenance. If I have 2 restaurants (for example) The easiest way to maintain their data is for each to have their own page and I'll use the content blocks etc to build those pages. However, if I have a chain of 100 restaurants, and I need to update their information on a regular basis, then really, they need a single management console in the dashboard or on a single page with a MySQL db backing it up.
Then again, if each restaurant was going to be updating their own page, then I would use pages for that I expect...
I agree, it is a bit of a fuzzy one at times and it's a nightmare if you go down one route and then really wish you'd gone the other way later!
Jon
Then again, if each restaurant was going to be updating their own page, then I would use pages for that I expect...
I agree, it is a bit of a fuzzy one at times and it's a nightmare if you go down one route and then really wish you'd gone the other way later!
Jon
if all the layouts of the pages are effectively the same(like yellowpages.com) then I would probably just build this in a database and have a single page as a view.
yoursite/restaurants/ (a big map or something or your search form)
yoursite/restaurants/region/ list all regions
yoursite/restaurants/region/midwest all midwest ones
yoursite/restaurants/details/id detail page
yoursite/restaurants/categories/asian-fusion
all asian-fusion restaurants
Not super hard to build, and I think more flexible. What if you need to put a banner ad on all 500 restaurant pages? if it is a single page, you add it once, you are done. I understand you can setup global blocks and setup blocks on children pages, but the single page is in my opinion the way to go. The time spent making the form to populate all this would be time well spent.
yoursite/restaurants/ (a big map or something or your search form)
yoursite/restaurants/region/ list all regions
yoursite/restaurants/region/midwest all midwest ones
yoursite/restaurants/details/id detail page
yoursite/restaurants/categories/asian-fusion
all asian-fusion restaurants
Not super hard to build, and I think more flexible. What if you need to put a banner ad on all 500 restaurant pages? if it is a single page, you add it once, you are done. I understand you can setup global blocks and setup blocks on children pages, but the single page is in my opinion the way to go. The time spent making the form to populate all this would be time well spent.
Yep - this is just what I'm referring to. I'm just beginning to use single pages (wow - that was easy!) and it's awesome how you can blend that in so easily. A few follow ups along these lines:
1. Does C5 automatically generate the variables from a URL like:
yoursite/restaurants/categories/asian-fusion
(e.g. does $_GET['categories']=='asian-fusion'?)
2. Assuming the data is in a database with single pages, what does C5 then give me? I could build it myself (probably easier) outside of the framework. Perhaps the answer is obvious (edit-ability on all other pages, plugins, etc.) - but I'm wondering if I'm missing something there.
3. If you want to give each restaurant owner access to their data (to update, etc.), then you would still use single pages? Would they log in through C5 and edit their record that way? Or outside of the C5 user functionality? (We have a few sites coming up that are crossing these lines and I'm still not completely clear as to the best practices here.)
Thanks everyone for your thoughts and feedback!
1. Does C5 automatically generate the variables from a URL like:
yoursite/restaurants/categories/asian-fusion
(e.g. does $_GET['categories']=='asian-fusion'?)
2. Assuming the data is in a database with single pages, what does C5 then give me? I could build it myself (probably easier) outside of the framework. Perhaps the answer is obvious (edit-ability on all other pages, plugins, etc.) - but I'm wondering if I'm missing something there.
3. If you want to give each restaurant owner access to their data (to update, etc.), then you would still use single pages? Would they log in through C5 and edit their record that way? Or outside of the C5 user functionality? (We have a few sites coming up that are crossing these lines and I'm still not completely clear as to the best practices here.)
Thanks everyone for your thoughts and feedback!
To answer your first question.
Concrete5 will pass your action function any additional URL parameters as function parameters.
I have a single page called 'dashboard/belong/members', one of the functions of members is 'detail' which requires an id.
The URL would be
http://.../dashboard/belong/members/detail/393...
Inside the controller for this single page I have:
Note: In this case my member model doesn't query the C5 database, it goes off and makes an SOAP request to another server and parses the membership record into a suitable object for use in the rest of my code.
After having used 'set' in the Controller, you can then just use $details in the view.
There are plenty of tutorials on how to properly do C5 MVC and utilising the C5 framework to do what you want.
Concrete5 will pass your action function any additional URL parameters as function parameters.
I have a single page called 'dashboard/belong/members', one of the functions of members is 'detail' which requires an id.
The URL would be
http://.../dashboard/belong/members/detail/393...
Inside the controller for this single page I have:
public function detail($id = null) { /* use model to get member detail */ Loader::model('member/detail', 'belong'); $details = BelongMemberDetail::getById($id); $this->set('details', $details); }
Note: In this case my member model doesn't query the C5 database, it goes off and makes an SOAP request to another server and parses the membership record into a suitable object for use in the rest of my code.
After having used 'set' in the Controller, you can then just use $details in the view.
There are plenty of tutorials on how to properly do C5 MVC and utilising the C5 framework to do what you want.
To chime in on question 2 - you can still add editable areas to your single page!
So if your single page is called restaurant.php - create a file called restaurant.php in the root of your theme. This will take precedence over the view.php template. You MUST have <?php echo $innerContent ?> somewhere in the file to get your single page output to display, but you can then also add editable areas, making it a proper CMS page.
Jon
So if your single page is called restaurant.php - create a file called restaurant.php in the root of your theme. This will take precedence over the view.php template. You MUST have <?php echo $innerContent ?> somewhere in the file to get your single page output to display, but you can then also add editable areas, making it a proper CMS page.
Jon