Showing articles only for members with a specific member level

5 posts by 2 authors in: Forums > CMS Builder
Last Post: November 20, 2013   (RSS)

By Dave - November 19, 2013

Hi Jerry, 

What's an estimate of the number of articles and authors you expect?

One way to do it is to do a query to get all the usernums who have a "master" level membership, then another query to load all articles that have been created by a user in that list of user nums.

Let me know, thanks!

Dave Edis - Senior Developer
interactivetools.com

By gkornbluth - November 19, 2013 - edited: January 3, 2014

Hi Dave,

Thanks for coming to my rescue again.

This is actually on the same  site that you just recently looked at. I used "articles" because I thought it was an easier concept to explain.

There are about 2500 possible "articles" (listings) and about 1600 user members. There are 3 membership categories possible for each user.

I can't say how many will ultimately be members in good standing (not hidden) and how many won't, but their listings and accounts never get deleted.

Hope that's the information you were looking for.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Dave - November 20, 2013

Hi Jerry, 

Maybe you could do a sub-query as a where.

So say you want to get a list of all the user numbers that have "a" in their username, here's a query for that:

SELECT num FROM cms_accounts WHERE username LIKE "%a%"

And then you want a list of all the articles:

SELECT * FROM cms_articles

Or a list of all the articles from created by users who have an "a" in their username:

SELECT * FROM cms_articles WHERE createdByUserNum IN (SELECT num FROM cms_accounts WHERE username LIKE "%a%")

Or as a getRecords option:

'where' => " createdByUserNum IN (SELECT num FROM cms_accounts WHERE username LIKE '%a%')", 

Would something like that work for you? 

Dave Edis - Senior Developer
interactivetools.com

By gkornbluth - November 20, 2013 - edited: November 20, 2013

Hi Dave,

That's just what I needed.

I used the last suggestion in the load records call, like this: (adding the requirement of the "status" field having the value "available")

 <?php // load records from 'lm_listing'
  list($lm_listingRecords, $lm_listingMetaData) = getRecords(array(
    'tableName'   => 'lm_listing',
    'loadUploads' => true,
     'where' => " createdByUserNum IN (SELECT num FROM cms_accounts WHERE internal_notes LIKE '%12.%') AND status = 'Available' ", ",
    'perPage' => $maximages,
  ));
 ?>

And it seems to work perfectly.

Thanks again,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php