Two related tables in CMS...

6 posts by 2 authors in: Forums > CMS Builder
Last Post: May 20, 2008   (RSS)

By rcrofoot - May 20, 2008

Hi Dave-

Based on the scenario I'm about to outline, when you get a chance, I would appreciate your opinion/suggestions:

In CMS Builder I already have a table (menu) called Featured Homes. This supplies main photos to a web page. When a user clicks one of the photos, a second page opens and displays additional photos related to the main photo just clicked...All photos (main and additional) are kept in this table...Simple...

Now my client wants to "categorize" the additional photos, so that when a main photo is clicked, the next page displays category links, e.g. Living Room, Kitchen, etc., and those categories may have up to 10 photos each...

My question is: What would be your recommendation on adding a second table to handle the category photos, vs. just adding the necessary fields to the existing Featured Homes table (there would be 10 upload fields accepting 10 photos each)...If I set up a second table, I'm assuming I (and not CMS) need to maintain the integrity between the 2 tables...I'm OK with databases, but not a whiz...Just trying to think this one thru a bit...

I would appreciate your insight and can send page links if that would clarify things more...

Thanks, Rick

Re: [rcrofoot] Two related tables in CMS...

By Dave - May 20, 2008

Hi Rick,

I'm thinking the simplest solution would be just to add additional upload fields for "Living Room", "Kitchen", etc.

That keeps it all clean and simple. Otherwise you'd need to click between sections when uploading photos.

Another option would be to use one of the extra upload meta fields (info3 say) for "Area". You could then have your uploads all together and (with a bit of custom code) only show uploads from certain areas in certain parts of the page. Or you could have it loop through and display a list of all the entered areas and let you click to see them. That would be a bit more work and complex though.

If you can get away with the first solution (just adding more fields), I'd try that first.

Hope that helps! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Two related tables in CMS...

By rcrofoot - May 20, 2008

Thanks Dave...Good point about how mixed up a listing and its associated photos could become, based on a user inputting between 2 tables...I'm going to work, as you suggested, with 1 table, and see how it develops...

(Great product & support!)

Rick

Re: [rcrofoot] Two related tables in CMS...

By rcrofoot - May 20, 2008

Dave-

Another quick question...

Before I get into this project too deep, I backed up the CMS tables using:

CREATE TABLE new_tablename SELECT * FROM existing_tablename;

This did the job, and I confirmed fields and data using a simple "SELECT * AS tablename" statement...all done in phpMyAdmin on our server...but when I go into CMS Builder and actually look at the new tables, I don't see any data, and the the CMS menu names, etc are not there...

Is there a way to backup the cms tables and their related support data, so I can restore in case of a mishap on my part???

Thanks, Rick

Re: [rcrofoot] Two related tables in CMS...

By Dave - May 20, 2008

Hi Rick,

Sounds like you know some MySQL. :)

You can backup the SQL data like that, and just download a copy of the /data/schema/ folder which has the CMS Builder specific settings for the fields.

CMS Builder will only show MySQL tables that start with the table prefix. So if that was "cms_" and you backed it up cms_news_backup. It would show up. And if you copied your schema to /data/schema/news_backup.ini.php you'd have all that data as well.

But you don't really need it to show up to have a backup. You just need to restore the table and the schema file. So you might not even have to go to all that hassle.

Hope that helps! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Two related tables in CMS...

By rcrofoot - May 20, 2008

Thanks...That did it...