getCategories() and Site Menu

2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 6, 2015   (RSS)

By Perchpole - April 6, 2015

Hello, All

I'm just about to complete a new CMSB website for a client which has taken quite a while to put together. As part of a tidying-up process I'd like to do some optimisation. In particular I am concerned about the size of the main "categories" table. It holds a ton of data - everything from meta tags to permalinks to what to show in the margins. As only one category "page" is ever shown at any one time this isn't normally a problem. However, what's more of a concern is the site navigation system. It uses the same getCategories() call but instead of one page it draws info from every category on the site.

To my way of thinking this one call must be the biggest drain on the server - but for very little return. Each item on the menu represents one category page but all I need from it is the name, num and globalOrder. All the other info mentioned above is completely unnecessary.

So, I've hit upon the idea of building the menu system with a query. It seems simple enough but am I making a fundamental error?

Also, by using a query I am unable to access pseudo elements such as _hasChild which is going to make child menu items harder to produce.

Thoughts please...

:0/

Perch

By ross - April 6, 2015

Hi Perch

Thanks for posting!

There are going to be a few different options for optimizing your code and for the most part, we will starting getting quite technical pretty much right away so I am not sure how far we'll get in the forum.  For now though, could you give me a list of the exact fields you need to pull from the database?

With that, I can start exploring my first idea with you. The idea will revolve around creating a custom SQL query and pulling out only the exact fields you need. That will help bring down the overhead just grabbing the entire database will require.   One thing to keep in mind here is that pseudo fields are going to take extra work in this method but there will likely be a MySQL way to get all the data needed so let's start with a list of fields and go from there.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/