Contentteller

Contentteller Support Forums
Home Forums > Contentteller > General Questions >

Article/Review Counter for Main page?

Discussion in 'General Questions' started by ReviewStud, May 12, 2009.

  1. ReviewStud New Member

    Article/Review Counter for Main page?

    I'll post this in the "Feedback and Suggestions" thread, but is there a way to create a counter on the main page that taunts of how many "news articles/reviews" you have you have posted except for one channel?

    Thanks,
    ReviewStud, May 12, 2009
    #1
  2. Philipp Administrator

    Here a block (attachment) that shows how many stories are in the database.

    1) Unzip the file and open news_count.php in an editor
    2) Replace 1a1a1a1a with the channel ID of the channel that should be excluded
    3) Upload news_count.php to the /blocks directory
    4) Select "Add New Block" in cadmin and choose "News count" as PHP Block Script

    Attached Files:

    • news_count.zip
      news_count.zip
      File size:
      504 bytes
      Views:
      28
    Philipp, May 12, 2009
    #2
  3. ReviewStud New Member

    That's works as a block, but I tried to do use it as a "{$insert['news_count']}" script, but I didn't get anything.

    I was thinking something more like this:

    <!-- Template: site_login_anon -->
    <h4>Welcome to URL.com</h4>
    <h5>The home of {$insert['news_count']} reviews.</h5>

    I am trying to limit how many L&R blocks I have on my site.
    ReviewStud, May 13, 2009
    #3
  4. Philipp Administrator

    The following should work. Add the following code to the PHP part of the template:

    PHP:
    global $database;

    $results = $database -> dbquery( "SELECT newsstory_id FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE NOT(newsstory_channels LIKE '%1a1a1a1a%')" );
    $insert['news_count'] = $database -> dbrows( $results );
    Philipp, May 13, 2009
    #4
  5. ReviewStud New Member

    This is what my news_count.php file looks like, but I'm not getting an output.

    HTML:
    <?php
    
    if( !defined( "CONTENTTELLER" ) )
    {
    	die( "Error" );
    }
    
    if( $preferences[ 'news_active' ] )
    {
    	$news_count = ( isset( $datastore[ 'news_count' ] ) ) ? $datastore[ 'news_count' ] : "" ;
    
    	if( !$news_count )
    	{
    		$results = $database -> dbquery( "SELECT newsstory_id FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE NOT(newsstory_channels LIKE '%e6781e67%')" );
    		echo "The home of " . $database -> dbrows( $results ) . " reviews.";
    
    		$system -> datastoreput( "news_count", $news_count );	
    
    	global $database;
    
    $results = $database -> dbquery( "SELECT newsstory_id FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE NOT(newsstory_channels LIKE '%e6781e67%')" ); $insert['news_count'] = $database -> dbrows( $results );
    	}
    
    	echo $news_count;
    }
    else
    {
    	echo "The news module is inactive";
    }
    ?>
    
    ReviewStud, May 15, 2009
    #5
  6. Philipp Administrator

    No, the PHP part of site_login_anon
    Philipp, May 15, 2009
    #6
  7. ReviewStud New Member

    Sorry, but where in the "site_login_anon" is the PHP? This is what I got, but I ain't getting anything from it. PHP isn't my thing.

    HTML:
    <!-- Template: site_login_anon -->
    <h4>Welcome to ReviewMagnet.com</h4>
    <h5>The home of {$insert['global $database;$results = $database -> dbquery( "SELECT newsstory_id FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE NOT(newsstory_channels LIKE '%e6781e67%')" ); $insert['news_count'] = $database -> dbrows( $results );']} reviews and counting.</h5>
    <h5>To take full advantage of all features you need to 
    <strong><a href="contentteller{$insert['param_ext']}{$insert['param_ct']}users{$insert['param_action']}login{$insert['param_page']}index.html" rel="nofollow">login</a></strong> or <strong><a href="contentteller{$insert['param_ext']}{$insert['param_ct']}users{$insert['param_action']}registration{$insert['param_page']}index.html" rel="nofollow">register</a></strong>. Registration is completely free and takes only a few seconds.</h5>
    
    ReviewStud, May 16, 2009
    #7
  8. Philipp Administrator

    Below the HTML part. You need to click "Add PHP part to this template" and a new field for the PHP appear.
    Philipp, May 16, 2009
    #8
  9. ReviewStud New Member

    That's did it. I was working on the file in Dreamweaver and was wonder were you were talking about. I was a bit confused.

    Thanks for the extra help.
    ReviewStud, May 17, 2009
    #9
  10. ReviewStud New Member

    How would I exclude a second channel in the news counter? I had to create another channel that isn't for reviews.
    ReviewStud, May 21, 2009
    #10
  11. Philipp Administrator

    This should do the trick:
    PHP:
    $results = $database -> dbquery( "SELECT newsstory_id FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE NOT(newsstory_channels LIKE '%1a1a1a1a%') OR NOT(newsstory_channels LIKE '%2b2b2b2b%')" );
    Philipp, May 21, 2009
    #11
  12. ReviewStud New Member

    Excellent!! That did the trick. I was leaving out the "OR" in the code.

    Thanks again,
    ReviewStud, May 22, 2009
    #12
  13. ReviewStud New Member

    Not sure why, but my article counter is back to counting "every" article, not all but two selected news channels. I haven't changed any of the PHP code in my site_login_anon or news_count files or anything in my MySQL database.

    Any ideas where I should start? I've gone over the code previously mentioned in this thread and haven't noticed any errors.

    HELP!
    ReviewStud, Jun 3, 2009
    #13
  14. Philipp Administrator

    Very odd. It worked before?
    Philipp, Jun 4, 2009
    #14
  15. ReviewStud New Member

    It worked perfectly until a few days ago, but now the counter is counting 'all' news articles.
    ReviewStud, Jun 6, 2009
    #15
  16. Philipp Administrator

    How does your current code look like?
    Philipp, Jun 6, 2009
    #16
  17. ReviewStud New Member

    I have the counter inside my site_login file.

    This is the code from my site_login_anon.php:

    HTML:
    global $database;
    
    $results = $database -> dbquery( "SELECT newsstory_id FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE NOT(newsstory_channels LIKE '%e6781e67%') OR NOT(newsstory_channels LIKE '%46c78256%')" ); 
    
    $insert['news_count'] = $database -> dbrows( $results );
    
    
    ReviewStud, Jun 6, 2009
    #17
  18. Philipp Administrator

    I see the problem. Changing OR to AND should fix the issue.
    Philipp, Jun 9, 2009
    #18
  19. ReviewStud New Member

    Changing it to "AND" fixed it.

    Thank you very much.
    ReviewStud, Jun 9, 2009
    #19
Tweet
Facebook:
Forgot your password?
Contentteller Support Forums
Home Forums > Contentteller > General Questions >
  • Home
  • Forums

    Forums

    Quick Links
    • Search Forums
    • What's New?
  • Members

    Members

    Quick Links
    • Registered Members
    • Current Visitors
    • Recent Activity
  • Help

    Help

    Quick Links
    • Smilies
    • BB Codes
    • Trophies

Separate names with a comma.

Advanced search...
    Forum software by XenForo™ ©2011 XenForo Ltd.