Using a Multi Record on a Category Menu page

10 posts by 3 authors in: Forums > CMS Builder
Last Post: March 14, 2011   (RSS)

By zip222 - March 3, 2011 - edited: March 27, 2011

I am building a site that uses a Category Menu to create all of the primary pages of the site. But I also trying to use a Multi Record for managing news and event listings. On one of the Category Menu pages I am displaying a list of news items. But I am having trouble setting up the detail page. I have been successful in getting the news detail information to display properly, but the menu that is generated from the Category Menu is not doing want I need it to do. Because I am sending a number at the end of the url for the news item, it is causing the Category Menu navigation to change as well. You can see what I am talking about here:

news list

Ideally I want the News category to stay highlighted.

Re: [zip222] Using a Multi Record on a Category Menu page

By Jason - March 7, 2011

Hi,

Can you attach show.php as well as the code that outputs your menu?

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [zip222] Using a Multi Record on a Category Menu page

By Jason - March 7, 2011

Hi,

I took a look at your code, and I think what's happening is you're not passing any category information in you're url.

You can try passing "page" in your url and then manually setting your WHERE clause to get your news using id and type instead of using whereRecordNumInUrl()

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Using a Multi Record on a Category Menu page

By zip222 - March 7, 2011

Jason, this sounds like it would work for me, but I am not sure how to proceed. Help?

Re: [zip222] Using a Multi Record on a Category Menu page

By Jason - March 8, 2011

Hi,

There are actually quite a few things happening on show.php. From what I can tell, the category being selected is being based on the last number in your URL string.

I would recommend starting out selecting your news/event record not using whereRecordNumInUrl(). Instead use the 'where' option to create your own where clause. Once that's working, you can pass your category number at the end of your url without worrying about how it will affect your record selection.

In order to give an exact example of how this is done, I would need to be able to see more of what's happening on your page and in your database, which isn't something we can handle through support. If you'd like us to take a look at getting this functionality working for you, please send an email to consulting@interactivetools.com and we can go over some options with you.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Using a Multi Record on a Category Menu page

By zip222 - March 8, 2011 - edited: March 8, 2011

I think I understand what you are suggesting, and I believe I am headed in the right direction....

I have changed the url structure to this:
show.php?type=news&newsid=2&page=4

This viewer code works correctly:
// load news record details
list($news_details, $news_detailsMetaData) = getRecords(array(
'tableName' => 'news_items_template',
'where' => 'num=2',
'limit' => '1',
));
$news_details = @$news_details[0]; // get first record


But if I modify the where statement to utilize the a number from the url it stops working. like this:

// load news record details
$newsnum = @$_GET["newsid"];

list($news_details, $news_detailsMetaData) = getRecords(array(
'tableName' => 'news_items_template',
'where' => "num='%\t$newsnum\t%'",
'limit' => '1',
));
$news_details = @$news_details[0]; // get first record


if i change my where statement to the following it works properly.

'where' => "num='{$newsid}'",

Re: [zip222] Using a Multi Record on a Category Menu page

By Jason - March 8, 2011

Hi,

A good way to do the where clause would be like this:

'where' => "num = '". mysql_escape($newsid)."' ",

we use mysql_escape to make sure no one is putting malicious code in the url string.

You would only use the "%" in the where clause when using the LIKE operator. Also, the tab characters("\t") are only used for multi-value lists.

Hope this helps clarify. Is everything working now?
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Using a Multi Record on a Category Menu page

By zip222 - March 8, 2011

Perfect. Everything seems to be working now.

jason

Re: [Jason] Using a Multi Record on a Category Menu page

By chop - March 14, 2011

thanks Jason, this really helped me.