How to tie a CCK (radio select) field and a MENU together programatically?

Events happening in the community are now at Drupal community events on www.drupal.org.
schedal's picture

Hello,

Looking into writing a custom trigger->action module.

But first I wanted to check if this has already been done.

Basically I have Panels which read the arg0 variable in the URL to call up Nodes that have a drop-down CCK field that matches the arg0 passed to it.

What I am missing, is a way for a MENU item to be automatically created at the same time [and with the same identifier] as a value in a radio-select field for Page_Area.

The problem right now is for a content_admin to add a page, they would need to add a CCK radio-select option [with the pipe of machine name and human-name] and they would then also need to make a menu item, using the machine name, with the correct path so that it calls the Panel... that's a lot to expect from a person who doesn't understand the word FTP and has problems just getting copy to look good in a WYSIWYG with more than 2 buttons... but still wants to be able to add/remove menu pages (aka areas aka Panels) themselves...

So, I'm looking to make the process easier.

I could imagine that either a MENU item gets created when a new item is added to the radio-select Page_Area.

OR

A new radio-select Page_Area is added when a new MENU item is created.

OR

Some totally different form/page where the content_admin can just see text fields with page names (which become radio's in Page_Area), and they can add/delete page names and it automatically creates/deletes [without them knowing] the correct MENU and adds/removes CCK-radio select boxes from the Page_Area.

Any of these solutions are good, and ideally the third from a usability perspective makes the most sense as it would present the end user with an ultra-dumb-easy experience.

Has this been done?

Would this be considered a trigger->action, or a module? If so I don't see anything relating to MENU and CCK; so I feel like this is more of a Module than a trigger/action combo, right?

Is there an easier solution than writing a trigger->action/module?

How have YOU addressed this issue with your clients? I must not be the only person who wants to let clients add/remove pages; but realizes that adding a menu-section often involves connecting it to other dynamic content variables... how do you solve this?

Thanks for your time and feedback!

Kindly,

Sebastian.

Comments

Ok so I have gotten to the

schedal's picture

Ok so I have gotten to the stage where I am looking at the mySQL tables for a given field, and it seems very oddly put together, with the human/system pairs being stored as part of a long string, instead of as different value pairs in a table... I have gotten to the point with my module development that I can access the radio button CCK data, and I can also access and write/read from the Menu; so this is all good news; but is this the best way to go? I am wondering if there is anyone who has done module development, in particular with CCK fields?

Thanks for any help / suggestions you may have to offer!

Best,

Sebastian.

From your description it

R.J. Steinert's picture

From your description it sounds like you have 3 requirements:

  1. an alternate menu admin that's based on the contents of a text box (in a custom form or a node?)

  2. A cck field that is also populated by the contents of this text box

  3. And lastly, pages that take an argument from the URL to only show nodes where your cck field == the argument

Correct?

Hello RJ, Thanks for

schedal's picture

Hello RJ,

Thanks for replying!

  1. yes, and I don't mind if it's from a form [custom module admin panel], or a node implementation; which ever is "easier" and "elegant"?
  2. yes, and ideally with the same format of: machine-name | human-friendly-name ; where the machine name would be "hidden" from the user in the form, and generated automatically [so strip spaces for under scrores etc. string replacement, that part is easy]
  3. I think I agree, only "pages" should really be Panels or Views, that take cck field as argument; but yes, I think you follow quite closely.
    :-)

If/when I can get this to work, it will mean that non-drupal admins [people who only barely understand how to edit a blog] can then also administer adding new menu items to websites that employ Panels and Views without having to match values in menu items manually. It also means that I can build very complex websites with just ONE node type, ONE View and ONE panel [because all the selection queries go through Panels/Views]; so really this module will facilitate a whole new era in user-friendly and clarity for both the admin and the content_user... at least, that's the master plan.
:-)

As stated above, my stumbling point is that CCK stores the values for radio/checkbox pairs in a seemingly very convoluted way, and in two different tables, and then in every node type as well... so I'm trying to figure out how I can use the CCK multi-select text field to do this, but I'm a little lost as to how to write/access the right part of the CCK's data table to read/write new paired values. I think if I can write/read that successfully, I'm guessing [crossing fingers] that the rest [menu read/write values] will be a lot easier.

My other idea is creating my very own datatable just for this module, and making my own multiselect box; but then I am not sure what extra effort is going to be required to get this custom-field to show up on the Views and Panels argument selector? If that is easy-as-pie, then perhaps that is a better strategy?

Thanks for any input/thoughts you may have!

Best regards,

Sebastian.

Your best bet would be to

R.J. Steinert's picture

Your best bet would be to look at the cck and menu modules. Instead of trying to replicate the required data structures in the database, use the function someone else has already written to add menu items/cck field entries. The same goes for retrieving the data. This also makes it easier to maintain your code in the future. If you find the right functions but are not sure how to form your data for the function, set a break point and use the already existing admin to form the data for you. If you don't have a debugger installed, using the firep() function to output the data to Firebug works nicely(requires DrupalForFirebug module and Firefox extension).

Portland (Oregon)

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: