Answer the question
In order to leave comments, you need to log in
How to output PHP code to another Joomla module file?
The question, in general, is probably simple, but I can’t figure out how to do it right.
There are two files - helper.php and default.php.
Helper, this is crap in which the connection to the database is processed.
And a default is an output in a template of the received data.
With the receipt of data, everything is fine, I receive.
<?php
defined('_JEXEC') or die;
class modCarouselHelper
{
public static function getCarousel()
{
$db = JFactory::getDbo();
$query = 'SELECT * FROM #__carousel';
$db->setQuery($query);
$carousels = $db->loadObjectList();
foreach ( $carousels as $carousel ) {
echo <<<HTML
<div>
<img src="{$carousel->slider_image}" alt="{$carousel->alt_image}">
</div>
HTML;
}
}
}
Answer the question
In order to leave comments, you need to log in
если default.php это шаблон, то похоже так:
...
foreach ( $carousels as $carousel ) {
include dirname(__FILE__).'/default.php';
}
...
<div>
<img src="<?=$carousel->slider_image?>" alt="<?=$carousel->alt_image?>">
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question