Excluding certain content/list

11 posts by 2 authors in: Forums > CMS Builder
Last Post: September 17, 2012   (RSS)

Hello,
I have two tables. One is for a place to upload some images. My other table is my about page where I am listing my content and pulling an image from the other table based on a drop down/list field within my about table. I have everything working fine. The issue is that I need to be able to exclude a category from the content that shows on my about page. I tried the following code but I cannot get it to exclude the Daily post entry from the page. See code below.

Here is my test page:
http://www.charlotteparent.com/indexfeed.php
Everything here is working perfectly except for excluding The Daily Post category.

Here is my code:
top of page:
<?php
require_once "C:/Inetpub/charlotteparent/cmsAdmin/lib/viewer_functions.php";

list($aboutRecords, $aboutMetaData) = getRecords(array(
'tableName' => 'about',
'where' => "header NOT LIKE '%\tThe Daily Post\t%'",
'limit' => '4',

));

?>

then in the body of my page:
<?php foreach ($aboutRecords as $record): ?>

<?php

$num = $record['header'];

list($header_images_smallRecords, $header_images_smallMetaData) = getRecords(array(
'tableName' => 'header_images_small',
'where' => "num ='$num'",

));


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


<?php foreach ($record['image'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>


<hr/>
<?php endforeach ?>

Title: <?php echo $record['title'] ?><br/>



<?php endforeach ?>


Thanks!
April

Re: [design9] Excluding certain content/list

Hi April

I think the problem is with the \t you have in the where statement. Have you tried removing them and doing something similar to this?:

list($aboutRecords, $aboutMetaData) = getRecords(array(
'tableName' => 'about',
'where' => "header NOT LIKE '%The Daily Post%'",
'limit' => '4',

));


The \t might be adding a space before and after the Daily post string, and these might not be saved in the table with the title.
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Excluding certain content/list

Thanks.

I tried that and that doesn't seem to work either.

April

Re: [design9] Excluding certain content/list

Hello,
I am having one other issue with this that I need some help with. When pulling in the content/image, it is working fine. It pulls the title and image form the header_images_small table with no problem. I also want to pull in the title and content fields from the about us section into that area. However, it is giving me an error because it is looking for those fields in the header_images_small table. Is there a way to also pull in the title and content fields for each listing from the about us section as well?

See ex. page:
http://www.charlotteparent.com/indexap.php

I have included my test page code to make it easier to look at.


Thanks!
April
Attachments:

indexap.php 2K

Re: [design9] Excluding certain content/list

Hi April,

Would it be possible for you to add the following code and then reply with the outputted array so that I can get a clearer idea of how all of the tables are linked?

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

<?php
showme($record);
exit();

$num = $record['header'];

list($header_images_smallRecords, $header_images_smallMetaData) = getRecords(array(
'tableName' => 'header_images_small',
'where' => "num ='$num'",

));


?>


I think maybe the header field is not where the the title of album is stored, and this is why it is still returning the daily post as well.

Could you also post me your updated code with the title and content fields in? This will help me with the showing blog_title and content fields issue.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Excluding certain content/list

Sure...Here is the output:

Array
(
[_filename] => The-Daily-Post
[_link] => javascript:alert('Set Detail Page Url for this section in: Admin > Section Editors > Viewer Urls')
[_tableName] => about
[blog_title] => Title 1
[content] => text 1
[createdByUserNum] => 1
[createdDate] => 2012-09-12 14:32:18
[dragSortOrder] => 40
[header] => 1
[header:labels] => Array
(
[0] => The Daily Post
)

[header:values] => Array
(
[0] => 1
)

[num] => 1
[title] => The Daily Post
[updatedByUserNum] => 1
[updatedDate] => 2012-09-13 10:14:30
[createdBy.num] => 1
[createdBy.createdDate] => 2009-02-04 22:16:32
[createdBy.createdByUserNum] => 0
[createdBy.updatedDate] => 2009-02-04 22:16:32
[createdBy.updatedByUserNum] => 0
[createdBy.username] => admin
[createdBy.email] => acraig@carolinaparent.com
[createdBy.fullname] => April Craig
[createdBy.expiresDate] => 0000-00-00 00:00:00
[createdBy.neverExpires] => 1
[createdBy.isAdmin] => 1
[createdBy.disabled] => 0
[createdBy.accessList] =>
[createdBy.lastLoginDate] => 2012-09-13 12:02:01
[createdBy._filename] =>
[createdBy._link] => javascript:alert('Set Detail Page Url for this section in: Admin > Section Editors > Viewer Urls')
)

Re: [design9] Excluding certain content/list

I have attached the code above in this post. I have the following tables:

Header_small_images table:
Title field
Image upload field

Then in my about table:
title field
header field - this is a list field that is using get options from database -advanced
values are num
labels are title
blog_title field
content field

Re: [design9] Excluding certain content/list

By gregThomas - September 13, 2012 - edited: September 13, 2012

Hi April,

Thank you for posting the array output. I think I have fixed both of the issues. I've re-attached the php file you posted earlier with the fixes in.

Instead of using a where statement to filter out the header labels I've used the in_array php function to search for the daily post instead. If it finds it, it will skip over that iteration of the foreach loop.

The second problem with the blog_title and content not displaying was caused by two of the foreach loops using $record in the as statement, and the second foreach loop was overwriting the content of the first. I've changed the names of the as statement to $about and $header_image.

Thanks
Greg Thomas







PHP Programmer - interactivetools.com
Attachments:

indexap_001.php 2K

Re: [greg] Excluding certain content/list

Thank you so much!

April