Keyword

check if item(s) in specific categories (by ID)

  • nicolas Bornet
  • nicolas Bornet's Avatar Topic Author
  • Offline
  • New Member
More
6 years 3 weeks ago #168905 by nicolas Bornet
check if item(s) in specific categories (by ID) was created by nicolas Bornet
Hello,
I'm looking for ways to condition the presence of active items in specific categories (by ID)
I need this condition on a category page.

This allows me to display or not module and text locations. the page is entirely lightened for this specific need.

example code that I use:

<?php if(count(JModuleHelper::getModules('partner-afrique'))): ?>
<h3 class="text-center thin"><?php echo JText::_('LC_BESPOKE_PARTNERS_AFRIQUE'); ?></h3>
<?php echo JHtml::_('content.prepare', '{loadposition partner-afrique}'); ?>
<?php endif; ?>

I looked on the forum and I did not find anything, nor on google.
can anyone help me?

Thank you

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #168983 by JoomlaWorks
Replied by JoomlaWorks on topic check if item(s) in specific categories (by ID)
Can you rephrase please? Be more specific and use shorter sentences in order for us to understand exactly what you want to achieve.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • nicolas Bornet
  • nicolas Bornet's Avatar Topic Author
  • Offline
  • New Member
More
6 years 2 weeks ago #168984 by nicolas Bornet
Replied by nicolas Bornet on topic check if item(s) in specific categories (by ID)
Hello,

i need to check if specifique category (by id) have Article (published).

TY

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #168990 by JoomlaWorks
Replied by JoomlaWorks on topic check if item(s) in specific categories (by ID)
Where exactly? In what context? Under the K2 component views only? The information you provide is too little.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • nicolas Bornet
  • nicolas Bornet's Avatar Topic Author
  • Offline
  • New Member
More
6 years 2 weeks ago #168992 by nicolas Bornet
Replied by nicolas Bornet on topic check if item(s) in specific categories (by ID)
In k2 category page.

i need to check it in category A with an override template category.php to check if article(s) are in category A-1, A-2, A-3 & A-4

i need only in k2 category page

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #168996 by JoomlaWorks
Replied by JoomlaWorks on topic check if item(s) in specific categories (by ID)
I'm really having a hard time understanding what you want to do...

- "i need to check it in category A": what exactly? The item? The category? Some module?

Do a screenshot if it's easier for you with marks (arrows) on what you see NOW and what you WANT to show.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • nicolas Bornet
  • nicolas Bornet's Avatar Topic Author
  • Offline
  • New Member
More
6 years 2 weeks ago #168997 by nicolas Bornet
Replied by nicolas Bornet on topic check if item(s) in specific categories (by ID)
Sorry, i don't speak english…

In this screenshot, i have a message from module newsshowpro : Error: No articles to display. and text "i nostri partner in america"
i need to hide wording and this position module (integrated in category page by this) :
<?php echo JHtml::_('content.prepare', '{loadposition partner-america}'); ?>
This message is write because i havent article in this language for this category (america)

For other line i haven't probleme because my client have write article in italian.

Sorry, if i'm not understandable

- "i need to check in category A page if category A-1 have item(s)"
Attachments:

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #169008 by JoomlaWorks
Replied by JoomlaWorks on topic check if item(s) in specific categories (by ID)
How is K2 related to this?

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • nicolas Bornet
  • nicolas Bornet's Avatar Topic Author
  • Offline
  • New Member
More
6 years 2 weeks ago #169015 by nicolas Bornet
Replied by nicolas Bornet on topic check if item(s) in specific categories (by ID)
Hummmm, because i work with K2 items and k2 category page.

But it does not matter. I will manage otherwise.

As I said, I'm just trying to check if a specific category contains articles to display a module position ...

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #169018 by JoomlaWorks
Replied by JoomlaWorks on topic check if item(s) in specific categories (by ID)
Do it differently. Allow the module to show, but make sure it has no chrome. Or better still, create your own module chrome (wrapper): docs.joomla.org/Applying_custom_module_chrome

Then modify mod_k2_content to retrieve the content you want. Delete everything that wraps the foreach() loop. If there is content, the foreach loop will populate the module. If not, your custom module chrome can check for any output by the K2 content module. Do a trim() for that. If it returns nothing, it means no K2 items where returned, and thus the module instance will never show up.

You can wrap the module chrome with something like:
<?php

// More info on custom module chromes here: https://docs.joomla.org/Applying_custom_module_chrome
function modChrome_customnamehere($module, &$params, &$attribs)
{
    if (!trim($module->content)) {
        echo '
            <div id="isModule'.$module->id.'">
                <h3>'.$module->title.'</h3>
                <div class="wrapperForModuleOutput">'.$module->content.'</div>
            </div>
        ';
    }
}

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum