This website can use cookies to improve the user experience

This website can use cookies to improve the user experience and to provide certain services and functions to users. Cookies contain small amounts of information (such as login information and user preferences) and will be stored on your device.

Enable All Cookies Privacy Policy

Latest news category(s) block


avatar
error 232
From: -
Latest news category(s) block

I have latest news block. It is pulled from all categories. What I want is pull news from specific news category like software, hardware, gadgets etc.

Latest Software News
Latest Hardware News
etc

Can i cusomize latest news in some way?

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


1 Re: Latest news category(s) block
avatar
135
From: -
I see. I thought I needed to add the channel_key in the SQL.

Thank you for clarifying that for me. It definitely works now.

ReviewStud Smiling Face with Sunglasses
1 Re: Latest news category(s) block
avatar
Editor
0
From: -
You need to keep $channel_key in the SQL query:
$results = $database -> dbquery( "SELECT newsstory_seo, newsstory_title FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE newsstory_channels LIKE '%".$channel_key."%' AND (newsstory_status = '0' OR newsstory_status = '3') AND newsstory_frontpage = '1' AND (newsstory_website = '0' OR newsstory_website = '" . $preferences[ 'current_website' ] . "')" . $news_expire_sql . " ORDER BY newsstory_date DESC LIMIT 10" );  
1 Re: Latest news category(s) block
avatar
135
From: -
Ok. I've found the channel_key number and inserted it into my "news_latest_news.php" file, but when I do this I get an error for an index page.

The MySQL database of this Contentteller Content Management System installation has encountered the following problem:
The MySQL database server has returned 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND newsstory_frontpage = '1' AND (newsstory_website = '0' OR newsstory_websit' at line 1 while executing SELECT newsstory_seo, newsstory_title FROM Contenttelleresselbach_ct_newsstories WHERE newsstory_channels LIKE '%%' = '0' OR newsstory_status = '3') AND newsstory_frontpage = '1' AND (newsstory_website = '0' OR newsstory_website = '1') AND newsstory_startdate < '2009-03-09 22:03:33' AND (newsstory_expiredate > '2009-03-09 22:03:33' OR newsstory_neverexpire = '1') ORDER BY newsstory_date DESC LIMIT 10

Please try it in a few minutes again. We apologise for any inconvenience.


This is the php code in the channel_key section:

$channel_key = "1a1a1a1a";

$results = $database -> dbquery( "SELECT newsstory_seo, newsstory_title FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE newsstory_channels LIKE '%".$e6781e67."%' = '0' OR newsstory_status = '3') AND newsstory_frontpage = '1' AND (newsstory_website = '0' OR newsstory_website = '" . $preferences[ 'current_website' ] . "')" . $news_expire_sql . " ORDER BY newsstory_date DESC LIMIT 10" );


If I change the "1a1a1a1a" to the "e6781e67z", then I get the same error as above.

I know I have a few articles in that channel, so it should be populating after I enable that category block. Instead, I get this error and no index page.

ReviewStud Confused Face
1 Re: Latest news category(s) block
avatar
Editor
0
From: -
You need to view the database in a database tool like  phpMyAdmin

Most webhosting companies have phpMyAdmin pre-installed as option in their control panel.
1 Re: Latest news category(s) block
avatar
135
From: -
Sweet!! So which file has the newschannel_key information?

"You need to set the channel_key to the key of your software or hardware channel/category.You find this information in the table esselbach_ct_newschannels under newschannel_key."


I can't find a esselback_ct_newschannels file or this table you mentioned. I created a news channel called "News". Is that all I need?
1 Re: Latest news category(s) block
avatar
Editor
0
From: -
Actually, this code is for news channels
1 Re: Latest news category(s) block
avatar
135
From: -
Is there a way to convert this code to pull the "Latest News" from only a news channel, not a category?

Thanks,

ReviewStud Smiling Face with Sunglasses
1 Re: Latest news category(s) block
avatar
Editor
0
From: -
1) Copy blocks/news_latest.php to blocks/news_latest_software.php, blocks/news_latest_hardware.php etc.
2) Modify the following in each file

Change:
$news_latest = ( isset( $datastore[ 'news_latest' ] ) ) ? $datastore[ 'news_latest' ] : "" ;


to (for software):
$news_latest = ( isset( $datastore[ 'news_latest_software' ] ) ) ? $datastore[ 'news_latest_software' ] : "" ;


or (for hardware):
$news_latest = ( isset( $datastore[ 'news_latest_hardware' ] ) ) ? $datastore[ 'news_latest_hardware' ] : "" ;


Change:
$results = $database -> dbquery( "SELECT newsstory_seo, newsstory_title FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE (newsstory_status = '0' OR newsstory_status = '3') AND newsstory_frontpage = '1' AND (newsstory_website = '0' OR newsstory_website = '" . $preferences[ 'current_website' ] . "')" . $news_expire_sql . " ORDER BY newsstory_date DESC LIMIT 10" );


to:
$channel_key = "1a1a1a1a";

$results = $database -> dbquery( "SELECT newsstory_seo, newsstory_title FROM " . DB_PREFIX . "esselbach_ct_newsstories WHERE newsstory_channels LIKE '%".$channel_key."%' AND (newsstory_status = '0' OR newsstory_status = '3') AND newsstory_frontpage = '1' AND (newsstory_website = '0' OR newsstory_website = '" . $preferences[ 'current_website' ] . "')" . $news_expire_sql . " ORDER BY newsstory_date DESC LIMIT 10" );


You need to set the channel_key to the key of your software or hardware channel/category. You find this information in the table esselbach_ct_newschannels under newschannel_key.

Change:
$system -> datastoreput( "news_latest", $news_latest );


to:
$system -> datastoreput( "news_latest_software", $news_latest );


or:
$system -> datastoreput( "news_latest_hardware", $news_latest );


3) Select "Add New Block" and select "News latest software" or "News latest hardware" as block script

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.