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

Forum

 

13 posts by 2 authors in: Forums > CMS Builder
Last Post: September 17, 2013

Example page - http://greens.exedor.us/projectsdetail.php?Copy-4-Baldwin-Hills-Pool-House-4

on the bottom of this page I need to add image/links to other in the same category  in this case Residential

<?php foreach ($projectsRecords as $record): ?>

<?php foreach ($projectsRecord['snapshot'] as $index => $upload): ?>
<?php if ($projectsRecord['project_type:label'] == 'Residential'): ?>

<a href="<?php echo $projectsRecord['_link'] ?>">
<img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" /></a>
<div style="color:#333333; font:Verdana; text-transform: uppercase"><b>
<?php echo htmlencode($projectsRecord['title']) ?></b></font></div>

<?php $maxCols=5; if (@++$count % $maxCols == 0): ?>
<?php endif; ?>
<?php endif; ?>

<?php endforeach ?>

I think what I am missing goes in the header part and not quite sure how to get the right stuff in there.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/greensul/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 record from 'projects'
list($projectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$projectsRecord = @$projectsRecords[0]; // get first record
if (!$projectsRecord) { dieWith404("Record not found!"); } // show error message if no record found

$title = "Greensulate Projects - Green roofs, green walls, and sustainable building consulting";

?>

Patricia
www.thenetgirl.com
Attachments:

projectsdetail.php 9K

Hi,

No problem.  So, if I'm understanding your code correctly, you on the project detail page you want to load all of the projects that have the same project_type as the project being displayed on the detail page (leaving out the currently displayed project as to not duplicate).  Is that right?

What's happening here is that $proejctsRecords will only ever load a single record.  Also, it is currently set to always load the first record it finds in the projects section, regardless of what's being passed in the URL.  What we need to do here would be to change your first getRecords call to load the correct record, and then have a second getRecords call to load all the related projects.

Try this:

  // load record from 'projects'
  list($projectsRecords, $projectsMetaData) = getRecords(array(
    'tableName'   => 'projects',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $projectsRecord = @$projectsRecords[0]; // get first record
  if (!$projectsRecord) { dieWith404("Record not found!"); } // show error message if no record found
  
  list($relatedProjects, $relatedProjectsMetaData) = getRecords(array(
    'tableName'  =>  'projects',
    'allowSearch'  =>  false,
    'where'        =>  "project_type = '".mysql_escape($projectsRecord['project_type'])."' AND num != '".intval($projectsRecord['num'])."'",
  ));

Give this a try and let me know if this returns the results you were expecting.

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/

NO just gave me a big fat error no show on the browser

Patricia
www.thenetgirl.com

Hi,

Can you please attach the entire PHP file so I can take a closer look at the code?

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/

Here you go just added the code and thats it ..not really sure how to go about doing anything to it.

Patricia
www.thenetgirl.com
Attachments:

projectsdetail_001.php 9K

Hi,

The first thing I noticed is that your new file is missing the connection to viewer_functions.php at the top


  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/greensul/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."); }

This is the most likely cause of the error you experienced, since there are no PHP syntax errors on the page.

I also noticed that in the "Related Projects" section of your page, you are still outputting the value from $projectsRecords instead of the new $relatedProjects variable.

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/

ah ha thanks let me fix all that

Patricia
www.thenetgirl.com

Yiiiiiiiiiiiiiiiiiiiiiiippppppppppppie  just got to get them in a row  think I can do that 

http://greens.exedor.us/1projectsdetail.php?Copy-4-Baldwin-Hills-Pool-House-4

I do have a stupid question I want a real list  <li> with bullet points on  cant seem to find that any where  - 

<ul> <li> <font face="Verdana" color="#000"><b><?php echo join(', ', $projectsRecord['size_type:values']); ?></li><br>
&nbsp;</b></font> </ul>

SIZE/TYPE

  • 1500 sf hybrid
  • Built-up system

And can you explain when you values and when you use labels < cant seem to get that.

THANKS JASON :-)

Patricia
www.thenetgirl.com

THANKS JASON :-)

Patricia
www.thenetgirl.com