Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Check, depending on language, if category got published articles

Check, depending on language, if category got published articles

Hello @all...

I just did a major error and killed my database. I already had it working and now I am struggling very hard to get back on track.

I got a two language site and I would like to do the following:

Depending on the active language, check in the corresponding category if there are any published articles. If not, display a defined module.


Seems easy and I already had it working... please, help!

I tried like this to check the category for published content...

Code:


If ($language_code == 'en')[b] // This works![/b]
{
if ( $content_genius->check("category_id = 5") != 0 ) return 124 ;
} [b]// This doesn´t work![/b]
If ($language_code == 'pt') {
if ( $content_genius->check("category_id = 4")!=0);
return 124 ;
}
return 102;

But it does not seem to work, as always "return 102;" is executed.

Edited By: XBit
21-Dec-11 16:54:58

XBit
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: Check, depending on language, if category got published articles

I found a "new" way to do, what I wanted to. I for sure not went this way before, but it works as well wink

Code:


$EngCat = 5; //Promo Category ID English
$PTCat = 4; //Promo Category ID Portugese
$count = 0; //Set variable

if ($language_code == "en" ) //Get the frontend language (using JoomFish)
{
$db =& JFactory::getDBO(); //Connect to wright database
$query = "SELECT COUNT(catid) FROM #__content WHERE catid = $EngCat and state = 1";  //Count the published articles in defined category ID
$db->setQuery($query); //Set the query
$count = $db->loadResult(); //Get the numbers!
if ($count == 0) {return 115;}  //Get another module when no promos active
else {return 124;} } //Display the promo module


//Same as before, just using new variables and language code

if ($language_code == "pt" ) {
$db =& JFactory::getDBO();
$query = "SELECT COUNT(catid) FROM `#__content` WHERE `catid` = $PTCat and `state` = 1"; 
$db->setQuery($query);
$count = $db->loadResult();
if ($count == 0) {
return 115;}
else {return 124;}  }


return 90; //Fallback if no Language detected

The whole idea behind it, is to display promotions depending on the language AND when there are none, displaying another module.

I post this for others looking for a solution.

Edit: I know there is a simpler solution, would be interested to hear your comments.

XBit
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: Check, depending on language, if category got published articles

Hi XBit,

actually I don't know of any faster ways to do this than what you've posted here. That's good PHP. JomGenius does not have any functionality for counting the number of published articles in a category.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1685
Total Polls:
6
Total Posts:
5912
Total Posts Today:
4
User Info:
 
Total Users:
11504
Newest User:
toko solo
Members Online:
0
Guests Online:
168

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked