Another Blog Question - Archives

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 24, 2012   (RSS)

Re: [dwelling] Another Blog Question - Archives

By Jason - January 24, 2012

Hi Jeremy,

What's happening here is you are using 2 separate queries that both use the variable name $blog_contentRecords. So your second query actually overwrites the results of your first. Also, you'll want to turn off automatic searching in your second query like this:

example
<!-- RECENT POSTS MODULE -->
<div id="BigRightBottom">
<h3 style="margin-left:-10px; color:#333;">RECENT POSTS</h3>
<?php
// load records
list($blog_recentRecords, $blog_recentMetaData) = getRecords(array(
'tableName' => 'blog_content',
'limit' => '7',
'loadUploads' => '0',
'orderBy' => 'createdDate DESC',
'allowSearch' => false,

));
?>
<p style="margin: 0px 10px 0px 10px;">
<?php foreach ($blog_recentRecords as $record): ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a><br />
<?php endforeach ?>
</p>
</div>


I also added an 'order' option to make sure the 7 most recent records get sorted to the top of your list.


The other thing I noticed is that you have a require_once statement part way down you page that includes viewer_functions.php. This line isn't necessary since you are already requiring this file up at the top of your page. This won't cause any errors, but removing it will help keep your code cleaner:


<!-- BLOG ARCHIVE MODULE -->
<div id="BigRightBottom">
<h3 style="margin-left:-10px; color:#333;">ARCHIVE</h3>
<p style="margin: 0px 10px 0px 10px;">
<?php require_once "/home/content/66/8739966/html/cmsAdmin/lib/viewer_functions.php"; ?>


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] Another Blog Question - Archives

By dwellingproductions - January 24, 2012

Thanks again Jason!!! You rock!!! :-)

Seriously, I really appreciate your taking the time to guide me to the solution for this (along with my other request). I learned a lot through the process of working on this that I'll definitely be able to apply to future CMSB projects.

Many (many, many, many) thanks!

- Jeremy
---------------------------

Dwelling Productions

www.dwellingproductions.com