Search
Other Advanced Module Manager questions
Forum

Trouble using Advanced Module Manager Condition php

André Schrogl's Avatar André Schrogl
Hi Mr. van Westen,

I am trying to figure out how the advanced module manager works. i would like to use php as the condition for the display. however, it does not work as i imagine. no matter what settings i make, the modules are always displayed. for example, i have set a simple statement in the condition to set the variable to false, yet the module is displayed. here is my example code for the condition. look forward to your assessment, best regards, andre
$unfallort = false; // Setzen Sie die Variable auf false

if ($unfallort) {
    return true; // Wenn die Variable true ist, wird das Modul angezeigt
} else {
    return false; // Wenn die Variable false ist, wird das Modul nicht angezeigt
}
Peter van Westen's Avatar Peter van Westen ADMIN
Based on your example code, the module should never show.

PS: this would do the same:
$unfallort = false;

return $unfallort;

Of course, a condition like this is pretty useless.

Does the module not show when using other conditions, like assigning it to a specific user (that is not you)?
Please post a rating at the Joomla! Extensions Directory
André Schrogl's Avatar André Schrogl
The code is of course not useful and only intended to not display the module as a test. with the test code I would like to exclude all other error sources. the module is always displayed, no matter what I have tried so far. I have just created a condition "CONDITION SET:
For Module: formular
Exclude Days
Tuesday", the module is still displayed. where else could the error be?
Peter van Westen's Avatar Peter van Westen ADMIN
It could be down to your template. Are you using a page builder?
Please post a rating at the Joomla! Extensions Directory
André Schrogl's Avatar André Schrogl
yes using pagebuilder but for testing i tried plain custom html modul. just found php setting was 8 and joomla 4 can handle 7.4 .... testing again..
Peter van Westen's Avatar Peter van Westen ADMIN
So this is probably caused by your template/page builder. Which could conflict with Advanced Module Manager.
If none of the conditions work, then that is the case.

It then probably means you will not be able to use Advanced Module Manager on your site.
Please post a rating at the Joomla! Extensions Directory
André Schrogl's Avatar André Schrogl
can this be also a reason?

There was an issue trying to check the validity of your Download Key.
Try again later.
Otherwise contact the Regular Labs support.
Please enter your Regular Labs Download Key:

key entered, but error
Peter van Westen's Avatar Peter van Westen ADMIN
That just means you can't check for updates or install them via the updater.
It doesn't interfere with the functionality of the extension itself.
Please post a rating at the Joomla! Extensions Directory
Christian Podlewski's Avatar Christian Podlewski
I have a similar problem. I made an override for the featured articles page for the cassiopeia template (I use a child template) and integrated a variable, which counts all articles displayed (incrementing within the existing foreach-loops). In a custom module I use the custom php condition to checking if there are no articles. The module should show on the page only, if that is true (that there are currently no featured articles). To check, if there are no articles, I wanted to use my variable from the template override, but my condition seems to be true in any case. I am grateful for any advice.


Condition:
return ( $zaehler == 0 );


Override of /templates/cassiopeia_landvolk_design_j4/html/com_content/featured/default.php
<?php

/**
 * @package     Joomla.Site
 * @subpackage  com_content
 *
 * @copyright   (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

?>
<?php $zaehler = 0 ; ?>
<div class="blog-featured" itemscope itemtype="https://schema.org/Blog">
    <?php if ($this->params->get('show_page_heading') != 0) : ?>
    <div class="page-header">
        <h1>
        <?php echo $this->escape($this->params->get('page_heading')); ?>
        </h1>
    </div>
    <?php endif; ?>

    <?php if (!empty($this->lead_items)) : ?>
        <div class="blog-items items-leading <?php echo $this->params->get('blog_class_leading'); ?>">
            <?php foreach ($this->lead_items as &$item) : ?>
                <div class="blog-item"
                    itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
                        <?php
						$zaehler++;
                        $this->item = & $item;
                        echo $this->loadTemplate('item');
                        ?>
                </div>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>
   
    <?php if (!empty($this->intro_items)) : ?>
        <?php $blogClass = $this->params->get('blog_class', ''); ?>
        <?php if ((int) $this->params->get('num_columns') > 1) : ?>
            <?php $blogClass .= (int) $this->params->get('multi_column_order', 0) === 0 ? ' masonry-' : ' columns-'; ?>
            <?php $blogClass .= (int) $this->params->get('num_columns'); ?>
        <?php endif; ?>
        <div class="blog-items <?php echo $blogClass; ?>">
        <?php foreach ($this->intro_items as $key => &$item) : ?>
            <div class="blog-item"
                itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
                    <?php
              		$zaehler++;
                    $this->item = & $item;
                    echo $this->loadTemplate('item');
                    ?>
            </div>
        <?php endforeach; ?>
        </div>
    <?php endif; ?>

    <?php if (!empty($this->link_items)) : ?>
        <div class="items-more">
            <?php echo $this->loadTemplate('links'); ?>
        </div>
    <?php endif; ?>
  	<?php if ( $zaehler == 0 ) : ?>
    <h2>Herzlich willkommen...</h2>
  
  	<?php $keinebeitraege = true; endif; ?>
  <?php echo $zaehler ; ?>
    <?php if ($this->params->def('show_pagination', 2) == 1  || ($this->params->get('show_pagination') == 2 && $this->pagination->pagesTotal > 1)) : ?>
        <div class="w-100">
            <?php if ($this->params->def('show_pagination_results', 1)) : ?>
                <p class="counter float-end pt-3 pe-2">
                    <?php echo $this->pagination->getPagesCounter(); ?>
                </p>
            <?php endif; ?>
            <?php echo $this->pagination->getPagesLinks(); ?>
        </div>
    <?php endif; ?>

</div>
Peter van Westen's Avatar Peter van Westen ADMIN
You can't just use a php variable you created in one file in an entirely different part (like a condition). That's not how php works.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription