Get list of Section Names

7 posts by 2 authors in: Forums > CMS Builder
Last Post: October 2, 2008   (RSS)

Sorry for this post, I searched the Forum but couldn't find the answer... maybe searching using the wrong terms.

How can I get a list of all the 'Sections' so that I can build a dynamic menu for my CMS site. I want to load each section into an array and then load the subPages so that I can create a simple menu like the sample below:

Section 1
- Page 1
- Page 2
- Page 3

Section 2
- Page 1
- Page 2
- Page 3

... and so on. The sections would be the section name in the CMS and the pages would be the titles.

I am sure this is something simple, but my brain is not catching it.

Thanks,
Doug

Re: [dougdrury] Get list of Section Names

Anyone have any ideas?

Re: [dougdrury] Get list of Section Names

By Dave - October 1, 2008

There's nothing officially supported for this - but you could try using this code:

<?php foreach (getSchemaTables() as $table): ?>
<?php echo $table ?><br/>
<?php endforeach ?>


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

Re: [dougdrury] Get list of Section Names

By dougdrury - October 1, 2008 - edited: October 1, 2008

Also, is there a way to get at the order of the main sections? I know over the editor you can reorder the sections, so somewhere it should be something I can read so I can order the sections the same way?

Does CMSBuilder have a way to send add hoc SQL queries to the database? I could then just do this myself without having to setup my own mysql_query() type calls.

Thanks,
Doug

Re: [dougdrury] Get list of Section Names

By Dave - October 2, 2008

Have you tried setting up a category section? That has a tree like structure built in by default.

For getting the schema's sorted by order you could try getSortedSchemas() eg:

<?php foreach (getSortedSchemas() as $tableName => $schema): ?>
...

As far as sending ad hoc SQL queries. I had thought about adding that, but by the time you're at that point it's pretty much as easy to do it with PHP functions such as mysql_query(). If you load viewer_functions.php first, though, it will automatically connect to the database for you so you won't have to do that.

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

Re: [Dave] Get list of Section Names

Dave,
Thanks. I will check these options out!!

Regards,
Doug