Strange Blog Results... Help^^

6 posts by 2 authors in: Forums > CMS Builder
Last Post: December 31, 2008   (RSS)

Re: [virgodesign] Strange Blog Results... Help^^

By Dave - December 27, 2008

Hi Avrom,

My first guess is that you have multiple viewers on the page and they're all trying to load their record numbers from the url with this line:

'where' => whereRecordNumberInUrl(1),

If you want your ads to load regardless of record number just remove that line from the getRecords() code. Or... Replace it with a where that isn't based on the number in the url.

Otherwise, if that doesn't fix it feel free to email me CMS and FTP login details to dave@interactivetools.com and I can take a look (email, don't post login details to the forum).

Hope that helps! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Strange Blog Results... Help^^

By avrom - December 30, 2008

Yes Dave, that was exactly it...

Many Thanks :)))

Re: [virgodesign] Strange Blog Results... Help^^

By avrom - December 31, 2008

Hi Dave,

I'm having another issue, and I am wondering if its the same issue - even though I have removed the 'where' => whereRecordNumberInUrl(1),

Warning: Invalid argument supplied for foreach() in includes/ads_250x80.php on line 12

This error only happens if no ads are in the record (or all hidden). But if there are ads in that record it displays fine. Any ideas off the top of your head ??

Here is the code:

<?php
require_once "cms/lib/viewer_functions.php";
list($ads_380x200Records, $ads_380x200MetaData) = getRecords(array(
'tableName' => 'ads_380x200',
//'where' => whereRecordNumberInUrl(1),
'orderBy' => 'RAND()',
'limit' => '1',
));
$ads_380x200Record = @$ads_380x200Records[0]; // get first record
?>
<!--Ads 380x200 -->
<div id="ad_block" class="block2">
<?php foreach ($ads_380x200Record['ad_upload'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<a href="<?php echo $ads_380x200Record['url'] ?>" target="_blank"><img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" title="<?php echo $ads_380x200Record['sponsor'] ?>" alt="<?php echo $ads_380x200Record['sponsor'] ?>" /></a>
<?php endif ?>
<?php endforeach ?>

<?php if (!$ads_380x200Record): ?>
<a href="advertise.php"><img src="images2/spacer.gif" width="380" height="200" /></a>
<?php endif ?>

</div>

Re: [virgodesign] Strange Blog Results... Help^^

By Dave - December 31, 2008

Hi Avrom,

You can put an "if" around the foreach so it doesn't run if there are no ads:

<?php if ($ads_380x200Record['ad_upload']): ?>
<?php foreach ($ads_380x200Record['ad_upload'] as $upload): ?>
...
<?php endforeach ?>
<?php endif ?>


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Strange Blog Results... Help^^

By avrom - December 31, 2008

Thanks Dave, perect !!