Just not understanding how to set up Category menus

44 posts by 5 authors in: Forums > CMS Builder
Last Post: September 22, 2009   (RSS)

By GraphicLingoes - September 9, 2009

I looked at the code for the plugin itself and your comments clarified what the injection field is. So if I understand correctly the injection field is being loaded as an array into the already loaded record allowing us to categorize links, etc...

This has really worked out great for my project. My client wanted a links section on the bottom of their site with five columns. In each column they wanted the ability to add sub sections with links per each sub section. With your plugin I was able to give them the functionality they wanted.

With the drag sort option they can even move the subsections around and with the hidden option they can removed them from the web site and add them later with the click of a check box!

It amazes me the cool functionality I find each time I use your product!
Graphic Lingoes
www.graphiclingoes.com

By Chris - September 9, 2009 - edited: September 9, 2009

So if I understand correctly the injection field is being loaded as an array into the already loaded record( s )...


@GraphicLingoes: Precisely. Great to hear this helped you out! Changing the name of the "injectionField" option is high on my list. I am definitely accepting ideas. :)


Now, your code for the detail page viewer is erroring with regards to equipment type. It happens whenever there is a 2-word named equipment type like "air compressors".


@equinox69: This has me baffled. The code is only supposed to supply MySQL with a list of numbers, not a list of "title" field values! Can you please send me both the PHP source code to that page which causes the MySQL error you had and your CMSB login info (in a private message, not in the forum please!) I'm very curious about what is wrong -- if there's something wrong with my plugin, I want to add some extra error checking so it can help people find the problem instead of throwing MySQL errors -- but first I have to figure out what went wrong.


Also, on the inventoryDetail.php page, what code do I use to display the equipment type?


@equinox69: Since there can be multiple Equipment Type records per Inventory record, you'll need a foreach to loop over them:

<?php if ( sizeof($record['equipment_type']) > 0 ): ?>
<?php foreach ($record['equipment_type'] as $equipment_typeRecord): ?>
<b><?php echo $equipment_typeRecord['title'] ?>&nbsp;</b>
<?php endforeach; ?>
<?php endif ?>


I hope this helps! Please let me know if you have any more questions.
All the best,
Chris

Re: [chris] Just not understanding how to set up Category menus

By Codee - September 15, 2009

Hi Chris,
3 things to answer your post:
1) what is your direct email address?
and,
2) I'm modifying a couple other pieces on this section and will then send that to you for review so that I'm not making changes while you are and vice-versa.
3) Inside the CMSB admin panel, when I click on the inventory menu to get the list of inventory records on the right hand side, the "Equipment Type" column is providing the #'s of the equipment type and not the title. How do we correct this or is this part of the plugin that has to be corrected?
Thanks!

Re: [equinox69] Just not understanding how to set up Category menus

By Chris - September 15, 2009

1. I get email from private forum messages. My email address is just as good, but if I post it here, the spam bots will get it. :)

2. Sounds good.

3. The plugin won't affect the CMSB admin panel at all. It sounds like maybe your Equipment Types field isn't configured properly. That would explain the previous errors too.

It should be set up like this:

Field Options:
Display As: pulldown (multi value)
List Options: Get options from database (advanced)
Section Tablename: equipment_type
Use this field for option values: num
Use this field for option labels: title


Do you perhaps have the field option values and labels switched around?

Hope this helps! :)
All the best,
Chris

Re: [chris] Just not understanding how to set up Category menus

By Codee - September 15, 2009

That's exactly how it's set up...is that backwards? Should I change it?

Additional Question, Re: [chris] Just not understanding how to set up Category menus

By Codee - September 16, 2009

Chris,
On a similar note, with regards to Manufacturer and Model fields. How do I get them to display, inside the CMSB admin panel's Inventory section in alphabetical order? Since they are entered one at a time I'm not able to just manually move the list around. There will be lots of manufacturers and lots of models so having them display by enter date when adding an inventory record is not the best way for the client...alphabetical would be much better.

Thanks!

Re: [equinox69] Just not understanding how to set up Category menus

By Chris - September 17, 2009

Hi equinox69,

I've attached a screenshot of that...


Your equipment_type field looks like it's set up correctly.

Oh, Equipment Type is showing as a number on the list page! I thought you meant that you had this behaviour on the add/edit record page. I'm not sure we have support for displaying multi-value fields' labels on the list page, but it's probably something we could do pretty quickly through consulting.

On a similar note, with regards to Manufacturer and Model fields. How do I get them to display, inside the CMSB admin panel's Inventory section in alphabetical order?


For one thing, you can click on the column headings on your Inventory list page to sort by that column. This isn't exactly an alphabetical sort because CMSB is sorting on the numbers in the field before converting them to labels. This helps the page load (much) faster if you have a large amount of records.

Also, in the Inventory section editor, you can set the default sorting under the Sorting tab. After changing this, you can get rid of the dragSortOrder field.

Ok, it seems everything is now working okay EXCEPT the equipment type in the CMSB admin panel...


Does this mean you're no longer having problems with Equipment Types which have spaces?

"MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Compressors)) ORDER BY dragSortOrder DESC' at line 3 "

All the best,
Chris

Re: [chris] Just not understanding how to set up Category menus

By Codee - September 17, 2009

Your equipment_type field looks like it's set up correctly.

Thanks, that's good.



Oh, Equipment Type is showing as a number on the list page! I thought you meant that you had this behaviour on the add/edit record page.

Actually, the problem IS on the add/edit record page. I've attached a newer screen shot with a red arrow and text pointing out the problem in the equipment type column of the inventory section within CMSB admin

I'm not sure we have support for displaying multi-value fields' labels on the list page, but it's probably something we could do pretty quickly through consulting.

Actually, If you mean the record list page inside the cmsb admin panel, I've never had a problem doing this. In fact, it's working right now on a couple sites that go back to version 1.23. I don't think it's a consulting kind of thing. I think where a problem may occur, especially for a newbie like me that's not a MysQl type programmer is when references need to be made to other sections from a different section's viewer or table.

Also, in the Inventory section editor, you can set the default sorting under the Sorting tab. After changing this, you can get rid of the dragSortOrder field.

Thanks, I used this to modify the manufacturer and equipment type order display, but in their own respective sections and not in the inventory section. So now when a record is added to inventory the manufacturer and equipment type dropdowns are in alphabetical order.

Does this mean you're no longer having problems with Equipment Types which have spaces?

This has been corrected...

...however there is still an issue or two relating to the functionality of the cool plugin. So, let's wipe the slate clean and I'll list the challenges below:
1. As mentioned in previous post and reply above...when on the inventory section record list screen (going to add/edit inventory records) the equipment type column displays the number and not the title of the equipment types. The manufacturer field works fine, displaying the name of the manufacturer. As mentioned earlier, screenshot is attached for your review and you have login details.

2. Issue not recognized before but related to the plugin issues and MySQL. When adding/editing an inventory record, if no manufacturer, model or equipment type is chosen then when a visitor clicks on the inventoryDetail.php page, they get a MySQL error that reads:
"MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) ORDER BY title' at line 3"
My guess this is a result of the viewer code you provided was not taken into account that these fields might be absent in a record:
// load referenced records for our fields
beta_lookupRelatedFields(array(
'table' => 'inventory',
'recordList' => &$inventoryRecords,
'fieldList' => array(
'manufacturer', 'model' => 'model', 'equipment_type'
),
));

The client does not want the manufacturer, model and equipment type fields to be set as 'required'.

Thanks for your help.
Attachments:

cmsb_admin_screenshot.jpg 67K

Re: [equinox69] Just not understanding how to set up Category menus

By Chris - September 17, 2009

Actually, the problem IS on the add/edit record page. I've attached a newer screen shot...


That's the list page. The add/edit record page is what you see after clicking "modify" or "create". I'm going to check into this some more and hopefully we can get the labels showing for you.

When adding/editing an inventory record, if no manufacturer, model or equipment type is chosen then when a visitor clicks on the inventoryDetail.php page, they get a MySQL error...


You deduced the problem perfectly! :)

I've attached a new version of the plugin which I hope addresses these cases. Please let me know if you run into any problems.
All the best,
Chris