Inserting different variables in JavaScript

13 posts by 4 authors in: Forums > CMS Builder
Last Post: February 24, 2014   (RSS)

Thanks Greg,

One small typo fix made it work perfectly.

I changed this:

 $items = array();
  if($record['use_submenu']']){

 To This:

$items = array();
  if($record['use_submenu'] == 1){

Now the only thing remaining is to make the menu entries dynamic.

Unless you can think of a better approach, I guess that I'll have to create a few new sections.

One section with fields for a dynamic list of values for 'entry' and for 'use_submenu, and another section for any submenu links associated with that entry value.

I'll post my progress.

Thanks again,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hi Jerry,

I think I can see what the problem is here. On the code that displays the HTML links, you're looping through the sub category menu items, so the number of menu items being displayed is the same as the number of sub category menu items for that particular item. 

I think the way to get around this would be to cycle through the category menu items instead. I think something like this would work:

<table  align="center" width="900px" border="0">
  <tr>
  <?php foreach ($new_menu_categoriesRecords as $record): ?>
    <?php $spaced_entry = preg_replace("/[-_]/", "&nbsp;", $record['title'] ); ?>
    <td width="16%" valign="top" align="center" ><a href="<?php echo strtolower(@$record['submenu_link_url']) ?>" class="menuanchorclass" rel="<?php echo strtolower($record['title']) ?>">
      <span class="sub_heading_font"><?php echo $spaced_entry ?></span></a>
    </td>
  <?php endforeach ?>
  </tr>
</table>

So instead of looping through the sub menu items and finding its parent link, we loop through the parents links instead.

The only potential issue I see is with the $record['submenu_link_url'] variable. I'm not sure if the parent categories has a submenu link URL field, or what link should be used if it doesn't.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com