Topic: Show news only in session language
Hi,
Yesterday there was a topic someone (i think rombest) asking how it would be possible to show news only in users language. But now i can not find that topic. I hope it was not a dream.
Here the solution is:
1. Open ext.news.php
Find:
$result = $DB->query("SELECT * FROM " . DB_PREFIX . "news WHERE active='1' ORDER BY $orderby $orderdir LIMIT $limit");Replace:
$filter_lng = '<div class="'.$SESSION->conf['language'].'-news"';
$result = $DB->query("SELECT * FROM " . DB_PREFIX . "news WHERE active='1' AND body LIKE '$filter_lng%' ORDER BY $orderby $orderdir LIMIT $limit");2. Open lib.news.php
Find:
$result = $DB->query("SELECT * FROM " . DB_PREFIX . "news WHERE active='1' ORDER BY postdate DESC, news_id DESC LIMIT " . (($page - 1) * $PREFS->conf['news_per_page']) . ", " . $PREFS->conf['news_per_page']);Replace:
$filter_lng = '<div class="'.$SESSION->conf['language'].'-news"';
$result = $DB->query("SELECT * FROM " . DB_PREFIX . "news WHERE active='1' AND body LIKE '$filter_lng%' ORDER BY postdate DESC, news_id DESC LIMIT " . (($page - 1) * $PREFS->conf['news_per_page']) . ", " . $PREFS->conf['news_per_page']);(For totalpages)
Find:
$result = $DB->query("SELECT COUNT(*) as total FROM " . DB_PREFIX . "news WHERE active='1'");Replace:
$filter_lng = '<div class="'.$SESSION->conf['language'].'-news"';
$result = $DB->query("SELECT COUNT(*) as total FROM " . DB_PREFIX . "news WHERE active='1' AND body LIKE '$filter_lng%'");3. While publishing news, at body section use the structure below.
Example English: <div class="english-news">English news body bla bla bla... </div>
Example French: <div class="french-news">French news body bla bla bla... </div>
Example Turkish: <div class="turkish-news">Turkish news body bla bla bla... </div>
If you have any questions feel free to ask.
Note: This could be done with adding an extra field for news too. But i think this is easier.
Important: Be sure news body starts with <div class=" not with <br>
Last edited by mystec (2009-12-01 03:59:04)