Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » Check, depending on language, if...
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.
21-Dec-11 16:54:58
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
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.
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
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » Check, depending on language, if...
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5967
- Total Posts Today:
- 2
- User Info:
- Total Users:
- 8027
- Newest User:
- henley7346
- Members Online:
- 1
- Guests Online:
- 171
- Online:
- henley7346
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked