Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

8 posts by 2 authors in: Forums > CMS Builder
Last Post: July 14, 2016

By rez - July 11, 2016 - edited: July 11, 2016

I have a list of proteins in CMSB (salad franchise). Around 50 of them in a table / section editor.

When clicking modify to edit the protein info, I have 8 restaurant locations load as a checkbox list form another editor. 8 checkboxes. 2 admins check location boxes to show which proteins are available at which locations. If a protein is checked for "Springfield" and "Jonestown", it will show in a protein list for that restaurant on that restaurant's location page.

This seemed to be the fastest way to have a couple of admins manage all the proteins for 8 locations. Having to click modify for each protein is time consuming for them but I dont see another way. 

That would get be me by. However, now the client is asking that they have the ability to schedule 3 or 4 weeks in advance. Daily proteins for each location... for 3 weeks? I'm stumped. I know there are schedule options in CMSB but how to schedule a list of proteins for each location for 3 weeks... ?

Any direction on this would be appreciated. I'm not opposed to starting over to make this work. The current setup was easy and now they hit me with this 2 days from launch. ugh!

Hi rez,

If I understand your setup and question correctly, to get "Today's Proteins" from Editor 3 for a location viewer page with location record num 1, use mysql_select() function with the following where clause:

For example:

$locationNum = '1';
$editor3Records = mysql_select("editor_3_tablename", "location LIKE '%\t".mysql_escape($locationNum)."\t%'");

The code above will return all the Editor 3 records where location num 1 is checked.
And in those records, the checked "proteins" are included.

You might need to expand the code above, ie. add scheduling to where clause, to match your needs.

Please let me know any further questions.

Cheers,

Daryl Maximo
PHP Programmer - interactivetools.com

By rez - July 13, 2016 - edited: July 13, 2016

Thanks. Each location page is getting the location num from the URL so I have this working on:

location-details.php?Canton-5:

  list($locationsRecords, $locationsMetaData) = getRecords(array(
    'tableName'   => 'locations',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $locationsRecord = @$locationsRecords[0]; // get first record
  if (!$locationsRecord) { dieWith404("Record not found!"); } // show error message if no record found
  
  unset($_GET['num']);
  unset($_REQUEST['num']);
  
  
  list($stateRecords, $stateMetaData) = getRecords(array(
    'tableName'   => 'state',
    'orderBy'     => 'name ASC'
  ));


// if location selected, make the multi selections
 if ($locationsRecords):
  list($proteinRecords, $proteinMetaData) = getRecords(array(
    'tableName' => 'schedule',
    'where' => "locations LIKE '%\t{$locationsRecord['num']}\t%' AND date = CURDATE()",
    //'debugSql' =>'true'
  ));
       endif;
       
             <h4 class="fsans">Today's Proteins</h4>          
           <ul class="no-bullet proteins">
               <?php foreach ($proteinRecords as $record): ?>
                 <li><?php echo join(', ', $record['protein:labels']); ?></li>
                <?php endforeach ?>
              </ul>

The "join" from the code generator puts all the proteins in one <li>. How do i get them to one protein per <li>?

<li>beef, chicken, tofu </li> <!-- currently -->

<li>beef</li>
<li>chicken</li>
<li>tofu</li> <!-- needed -->

Something to do with explode and loop them into a list? I don't recall having to use "join" in the first place to list these out in the past but couldn't get them to display otherwise. Thanks for your help. This will work great when i have them in a list. Please let me know how to do that and if my code above is efficient for this situation.

By rez - July 13, 2016 - edited: July 13, 2016

Actually, i have another question I can't find in a search.

In the editor, "Schedule", I pull in a multi list of checkboxes from the "Proteins" table. using the advanced option with num as value and label as name. 3 of these proteins, they have every day. Can an admin load these 3 already checked by default when creating a new schedule record (there are around 50 protein checkboxes / items)? 

Hi rez,

> Something to do with explode and loop them into a list? 

That's right, explode it with ", " as separator then loop through each.

> Can an admin load these 3 already checked by default when creating a new schedule record (there are around 50 protein checkboxes / items)? 

Yes, one way to do that is by creating a custom plugin that is hooked to 'adminUI_args' filter where the plugin function will insert additional get parameter to the "Create" button's redirect onClick URL.
ie:

[onclick] => window.location='?menu=sample_multi_record&amp;action=add&amp;proteins[]=1,2,3

where 'proteins' is you multi-checkbox field name and "1, 2, and 3" are the record num of proteins that you'd like to be checked by default.

You can check an example of how to use the plugin filter on this post:
http://www.interactivetools.com/forum/forum-posts.php?postNum=2239157#post2239157

Cheers,

Daryl Maximo
PHP Programmer - interactivetools.com

By rez - July 13, 2016 - edited: July 13, 2016

This seems powerful. Is there documentation to understand more? I only sort of get it. "action"? What are possible actions? That's CMSB plugin stuff?

The only thing I can think of is to get some custom work with heavy commenting to point me where to learn more. It probably isn't a big job to get this done. 

Or where can I learn more possibilities for filters and the plugin system and how to utilize this besides the link you gave?

hmm. Can jquery be used in a plugin or this filter situation when pressing the create button (to fill checkboxes for instance)?

Yes, it's powerful as it lets you customize the CMS admin. And as far as I know, we don't have available documentation for the plugin hooks. 
But we do have free plugins that use some of it, ie: Save & Copy, Modify Header Links, that you can check and see how it works.
Additionally, you can find the list of this hooks at YOURSITE/cmsb/admin.php?menu=admin&action=pluginHooks

Can jquery be used in a plugin or this filter situation when pressing the create button (to fill checkboxes for instance)?
- I don't think so because the click event of the create button will not get register on the next page (add new record page)

Note: Always make a backup when you're trying out a hook as it might break your CMS admin.

Daryl Maximo
PHP Programmer - interactivetools.com