Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.


XBit
Beginner Modder
ranks
useravatar
User Info

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

Administrator has disabled public posting
XBit
Beginner Modder
ranks
useravatar
User Info

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.


Administrator has disabled public posting
metamodguy
useravatar
User Info

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

Administrator has disabled public posting

Board Info

Board Stats:   Total Users: 3096  Total Topics: 1195  Total Polls: 7  Total Posts: 4450  Posts this week: 13
User Info:   Newest User :  consyder   Members Online: 1   Guests Online: 106
Online 
Jeff78
Topic
New
Locked
Topic
New
Locked
Sticky
Active
New/Active
Sticky
Active
New/Active
New/Closed
New Sticky
Closed/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky Active Locked
Active/Sticky
Sticky/Locked
Sticky/Active/Locked