gantry5 icon indicating copy to clipboard operation
gantry5 copied to clipboard

Where did Platform.php go?

Open newjie opened this issue 2 years ago • 0 comments

It was around 2 years ago I made some modification to /libraries/gantry5/classes/Gantry/Framework/platform.php:

public function displayRandomModules($position, $attribs = []){
  $document = \JFactory::getDocument();
  if (!$document instanceof \JDocumentHTML) {
      return '';
  }

  $html = '';
  $pick = array_rand(range(0,17),3);
  foreach (\JModuleHelper::getModules($position) as $key=>$module) {
    if (in_array($key,$pick)){
      $html .= $this->displayModule($module, $attribs);
    }
  }

  return $html;
}

I have 18 modules assigned to a same position, and I use this to randomly display 3 of them in custom/engine/particle/position.html.twig

{% block particle %}
    {% if attribute(gantry.platform,'displayRandomModules') is defined and particle.key == 'sidebar-right-homepage' %}
      {{ gantry.platform.displayRandomModules(particle.key, {'style': particle.chrome|default('gantry')})|raw }}
    {% else %}
      {{ gantry.platform.displayModules(particle.key, {'style': particle.chrome|default('gantry')})|raw }}
    {% endif %}
{% endblock %}

I know this is not the best practice because these codes get overriden. Now with the latest version this platform.php file is gone. Where should I apply the changes?

newjie avatar Aug 01 '22 01:08 newjie