Featured Article from existing Articles section
12 posts by 2 authors in: Forums > CMS Builder
Last Post: January 14, 2010 (RSS)
By design9 - January 14, 2010
Hi Chris,
I figured out how to get the article to show in the featured area but now I am having another issue. I have 2 seperate sections on the page, one that pulls in the id number to the featured article area of the page and then another area that lists all articles for that category. The issue now is that since I have placed the new coding to pull in the article into the featured article by id number, it is no longer listing all articles for the category in the "all articles section. It is actually only pulling the 3 articles where I had entered the id number for the featured section. I want the all articles section to pull all articles for the category elementary years. Here is examples of the pages so you can see what I am talking about:
http://www.carolinaparent.com/test/elementary.php
On this page, you can see that the articles are pulling in correctly into the featured article section but for the all articles section it shoews only those 3 articles instead of all articles.
http://www.carolinaparent.com/test/elementary1.php
This page shows only the all articles section and all the various articles that should be pulling in for that area.
Here is the code used on the page :
<?php
require_once "d:/hosting/member/acraig/site1/cmsadmin/lib/viewer_functions.php";
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => " category LIKE '%\tElementary Years\t%' ",
));
list($elementaryRecords, $elementaryMetaData) = getRecords(array(
'tableName' => 'elementary',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$elementaryRecord = @$elementaryRecords[0]; // get first record
// show error message if no matching record is found
if (!$elementaryRecord) {
print "Record not found!";
exit;
}
$articleRecords = array();
if ($elementaryRecord['featured_article_nums']) {
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => 'num IN (' . $elementaryRecord['featured_article_nums'] . ')',
));
}
?>
<body>
<table width="651" border="0">
<tr>
<td width="227" height="886"></td>
<td width="27"> </td>
</tr>
</table>
<table width="651" border="0">
<tr>
<td width="48" height="177"> </td> <?php foreach ($articlesRecords as $record): ?>
<td colspan="3" width="577" height="177"><a href="<?php echo $record['_link'] ?>"><span class="titlebig"><?php echo $record['title'] ?></span></a><br>
<span class="bodytext"><?php echo $record['summary'] ?>
<?php endforeach; ?></span></td>
<td width="26"> </td>
</tr>
</table>
<?php foreach ($articlesRecords as $record): ?>
<table width="650" border="0">
<tr>
<td width="47"> </td>
<td width="23"><img src="../greendot.jpg" alt="" width="23" height="22"></td>
<td width="462"><a href="<?php echo $record['_link'] ?>"><span class="titlebig"><?php echo $record['title'] ?></span></a></td>
<td width="72"><a href="<?php echo $record['_link'] ?>" class="links"><strong>Read more</strong></a> </td>
<td width="24"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"><span class="bodytext"><?php echo $record['summary'] ?>
</span></td>
<td> </td>
</tr>
</table>
<p>
<?php endforeach; ?>
</p>
</body>
</html>
I have also attached the page as well.
Thanks!
april
I figured out how to get the article to show in the featured area but now I am having another issue. I have 2 seperate sections on the page, one that pulls in the id number to the featured article area of the page and then another area that lists all articles for that category. The issue now is that since I have placed the new coding to pull in the article into the featured article by id number, it is no longer listing all articles for the category in the "all articles section. It is actually only pulling the 3 articles where I had entered the id number for the featured section. I want the all articles section to pull all articles for the category elementary years. Here is examples of the pages so you can see what I am talking about:
http://www.carolinaparent.com/test/elementary.php
On this page, you can see that the articles are pulling in correctly into the featured article section but for the all articles section it shoews only those 3 articles instead of all articles.
http://www.carolinaparent.com/test/elementary1.php
This page shows only the all articles section and all the various articles that should be pulling in for that area.
Here is the code used on the page :
<?php
require_once "d:/hosting/member/acraig/site1/cmsadmin/lib/viewer_functions.php";
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => " category LIKE '%\tElementary Years\t%' ",
));
list($elementaryRecords, $elementaryMetaData) = getRecords(array(
'tableName' => 'elementary',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$elementaryRecord = @$elementaryRecords[0]; // get first record
// show error message if no matching record is found
if (!$elementaryRecord) {
print "Record not found!";
exit;
}
$articleRecords = array();
if ($elementaryRecord['featured_article_nums']) {
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => 'num IN (' . $elementaryRecord['featured_article_nums'] . ')',
));
}
?>
<body>
<table width="651" border="0">
<tr>
<td width="227" height="886"></td>
<td width="27"> </td>
</tr>
</table>
<table width="651" border="0">
<tr>
<td width="48" height="177"> </td> <?php foreach ($articlesRecords as $record): ?>
<td colspan="3" width="577" height="177"><a href="<?php echo $record['_link'] ?>"><span class="titlebig"><?php echo $record['title'] ?></span></a><br>
<span class="bodytext"><?php echo $record['summary'] ?>
<?php endforeach; ?></span></td>
<td width="26"> </td>
</tr>
</table>
<?php foreach ($articlesRecords as $record): ?>
<table width="650" border="0">
<tr>
<td width="47"> </td>
<td width="23"><img src="../greendot.jpg" alt="" width="23" height="22"></td>
<td width="462"><a href="<?php echo $record['_link'] ?>"><span class="titlebig"><?php echo $record['title'] ?></span></a></td>
<td width="72"><a href="<?php echo $record['_link'] ?>" class="links"><strong>Read more</strong></a> </td>
<td width="24"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"><span class="bodytext"><?php echo $record['summary'] ?>
</span></td>
<td> </td>
</tr>
</table>
<p>
<?php endforeach; ?>
</p>
</body>
</html>
I have also attached the page as well.
Thanks!
april
Re: [apdance9] Featured Article from existing Articles section
By Chris - January 14, 2010
Hi April,
The problem here is that you're using the same variable name for both lists of records. When you do the second getRecords(), (which gets your featured articles,) you're overwriting your list of all articles for the category. The solution is to use two separate variable names, changes in red:
I hope this helps! Please let me know if you have any questions. :)
The problem here is that you're using the same variable name for both lists of records. When you do the second getRecords(), (which gets your featured articles,) you're overwriting your list of all articles for the category. The solution is to use two separate variable names, changes in red:
list($allArticlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => " category LIKE '%\tElementary Years\t%' ",
));
...
list($featuredArticlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => 'num IN (' . $elementaryRecord['featured_article_nums'] . ')',
));
...
<td width="48" height="177"> </td><?php foreach ($featuredArticlesRecords as $record): ?>
...
<?php foreach ($allArticlesRecords as $record): ?>
I hope this helps! Please let me know if you have any questions. :)
All the best,
Chris
Chris