Category Menu

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

Re: [laurie34117] Category Menu

Hi Laurie,

Can you describe what you're attempting to accomplish and where you're stuck in another way?

Thanks,

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

Re: [gkornbluth] Category Menu

By (Deleted User) - March 17, 2011

Specifically have the link generated from the category menu section be more specific to the page it is referring to. Currently the "Showroom" link is this: http://europianosnaples.com/categoryList.php?Showroom-1

So I would have to name the showroom page categoryList.php?Showroom-1 rather than simply Showroom.php

Re: [laurie34117] Category Menu

By robin - March 17, 2011

Hey Laurie,

Thanks for the question. If you have a section named Category that will list links to different pages - you'll need to add a field (if you haven't done so) to Category to store the custom link. Then modify what the code generator outputs slightly. If you post the code you're using for that page I can show you how to change it.

Thanks,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Category Menu

By (Deleted User) - March 17, 2011

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/manchen1/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($categoryRecords, $categoryMetaData) = getRecords(array(
'tableName' => 'category',
));

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>



<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Sample Navigation Menu</h1>
<?php foreach ($categoryRecords as $record): ?>
<?php echo str_repeat("&nbsp; &nbsp; &nbsp;", @$record['depth']) ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['name'] ?></a><br/>
<?php endforeach ?>

<?php if (!$categoryRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->

</body>
</html>

Re: [laurie34117] Category Menu

By robin - March 17, 2011

Hey Laurie,

Do you have a field in "Category" to store the link you want to use? Let me know if you need help creating one.

Thanks
Robin
Programmer
interactivetools.com

Re: [robin] Category Menu

By (Deleted User) - March 17, 2011

I can add the field... what type of field should it be?

Re: [laurie34117] Category Menu

By robin - March 17, 2011

Hey Laurie,

A text field will be fine for storing something like: "rare_antique_pianos.php".

Robin
Robin
Programmer
interactivetools.com

Re: [robin] Category Menu

By (Deleted User) - March 17, 2011

I added a text field "link" to the category section

Re: [laurie34117] Category Menu

By robin - March 17, 2011

Allright,

Once you've filled out your new link field for each category. Make the code change below and you should be good. I just changed ['_link'] to the name of your new link field ['link'].

<a href="<?php echo $record['_link'] ?>"><?php echo $record['name'] ?></a><br/>
To:
<a href="<?php echo $record['link'] ?>"><?php echo $record['name'] ?></a><br/>

Please let me know if you have any more questions.
Robin
Robin
Programmer
interactivetools.com