where filter that uses a field name?

19 posts by 5 authors in: Forums > CMS Builder
Last Post: June 25, 2010   (RSS)

By Chris - June 18, 2010

Hi studio-a,

I think the simplest solution is to use the category's record number in the URL. You can have both the category's record number and name in the URL for SEO/readability purposes, just like how detail pages work.

Can you please post the complete PHP source code for the page you're working on?
All the best,
Chris

Re: [chris] where filter that uses a field name?

By studio-a - June 18, 2010 - edited: June 19, 2010

Hi Chris,

Thanks for getting back with us. We have uploaded the php file for the test listing page. You will note a variety of php lines of code rendered out.

We are interested in using the URL with the category number and name with the SEO/readability.

BELOW IS OUR SETUP.

table 01 = service_categories
textfield within this table = category_name
textbox within this table = summary

table 02 = service_titles
droplist within this table = category (this is being dynamically populated from table 01 textfield category_name)
textfield within this table = service_title
textbox within this table = description

Our objective is to create List Pages for EACH Service Category while displaying the category_name and summary at the top of each page followed by the list of service_titles and descriptions associated with the dynamically created category_name(s) grouping. In addition, we will need to include the page links.

As you can see within the php test page we have the information for the page created, we're just not sure how to query the database since we are using two tables. Let me ask, "Using two tables for this dynamic menu setup - is this a good strategy? Is there a better way to offer the client a dynamic way of creating interactive menus?"

Thanks for your help and time. We look forward to hearing your reply!

studio-a
Attachments:

list-test.php 4K

By Jason - June 21, 2010

Hi,

To clarify, on your page, are you wanting to display all service_categories records? Or just one that has been selected?

Also, how are you associating a service_title record with a category? Is there a category field in the service_titles table? If so, what are you storing there, a number or a name?

Let me know and we'll see if we can get this sorted out for you.
---------------------------------------------------
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] where filter that uses a field name?

By studio-a - June 21, 2010 - edited: June 21, 2010

Hi Jason,

Jason asked: Do you want to display all service_categories records? Or just one that has been selected?
studio-a answer: Just the one selected and link with the services titles. Page output display is written below.

PAGE DISPLAY BELOW.
------------------------------------------------------
category_name
summary

service_title
description

service_title
description

service_title
description

<< pagination >>


Jason asked: How are you associating a service_title record with a category?
studio-a answer: We are associating the service titles with the service categories via the drop down list referencing another table (see Admin Set Listed Below AND attached jpg).

ADMIN SETUP BELOW.
------------------------------------------------------
table 01 = service_categories
textfield within this table = category_name
textbox within this table = summary

table 02 = service_titles
droplist within this table = category (this is being dynamically populated from table 01 textfield category_name - see attached image for cross table setup)
textfield within this table = service_title
textbox within this table = description

Looking forward to your help.

studio-a

P.S. We have the page working, but the pagination is now causing a problem. See other post at: http://www.interactivetools.com/forum/gforum.cgi?post=81347#81347
Attachments:

form_dynaimc_categories.jpg 296K

By Jason - June 21, 2010

Hi,

Okay, first we need to select the correct category. Since we're sending the categories name, and not the number, in the url, we need to know how our url is being formatted.

For example:
list.test-1.php?category=*CATEGORY NAME*

For this example, we'll assume this is how it's being done.

Step 1, select the correct category:
list($service_categoriesRecords, $service_categoriesMetaData) = getRecords(array(
'tableName' => 'service_categories',
'where' => "category_name='".mysql_escape(@$_REQUEST['category'])."'"
));

if($service_categoriesRecords){
$category=$service_categoriesRecords[0];
}
else{
echo "Category Not Found";
exit;
}


Next we need to select the correct service title records based on the category number of the category we selected:

list($service_titlesRecords, $service_titlesMetaData) = getRecords(array(
'tableName' => 'service_titles',
'where' => "category=".intval($category['num']),
'perPage' => '10',
));


We now have all of the service_title records associated with that category stored in $service_titlesRecords.

So, we can output the category information like this:

<?php echo $category['category_name'];?>
<?php echo $category['summary];?>


And we can output all the service title information like this:

<?php foreach($service_titlesRecords as $service_title): ?>
<?php echo $service_title['service_title']; ?>
<?php echo $service_title['description'];?>
<?php endforeach ?>


Give this a try and let me know how it works out for 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/

By Jason - June 24, 2010

Hi,

If you could email you cms login and FTP details to jason@interactivetools.com, I can take a look into this for you.

Please only send this information by email.

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: [Jason] where filter that uses a field name?

By studio-a - June 24, 2010 - edited: June 24, 2010

Hi Jason,

We sent you the ftp and cms login info you requested, but we understand things get busy. Attached is the serviceListTest.php file we have been testing using the code you recommended. As we mentioned, the Category Name along with its Summary are displayed when using the URL format (listed below) and your suggested code. However, no Service Titles show up?

For Example: www.mydomain.com/pages/serviceListTest.php?category=Cat Name Here

If anyone can help us we appreciate your time.

Thanks,

studio-a

By Jason - June 25, 2010

Hi,

The problem seemed to be where we were selecting the category record. If i used the URL format that you listed below, it gave me a "Page Not Found" error, probably do to a reWrite in a .htaccess file.

However, if I changed it to this format:
www.mydomain.com/pages/serviceListTest.php?service_categories=Category Name Here

It would work. The only other change was to change the getRecords request to use "@$_REQUEST['service_categories']".

Take a look and confirm that things are working the way you want now.

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/