New answers tagged

3

You can use the following: $menu = Joomla\CMS\Factory::getApplication()->getMenu(); $menuItem = $menu->getItem($menulink); echo $menuItem->title; If you var_dump($menuItem);, it will show you which properties are available for said menu item.


2

Access the link fields the same way you're accessing other fields, through the main activities field. <?php foreach ((array) $activities as $activity) : ?> <?php foreach ((array) $activity->links as $link) : ?> <?php echo $link->menulink; ?> <?php endforeach; ?> <?php endforeach; ?>


3

Start with: $assoc = $db->loadAssoc(); https://docs.joomla.org/Selecting_data_using_JDatabase#loadAssoc.28.29 This will provide a flat, associative result set array: $assoc = [ 'AIG' => '88,32', 'ALLIANZ' => '86,96', 'LLOYDS' => '118,11', ]; Then prepare the results for sorting by creating a new column as the first element that ...


2

Resolved this as follows: In foreach, for the intro image, I replaced $introimage = $r->images; with $introimage = json_decode($r->images)->image_intro; For the date formatting, I added: use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; and replaced echo '<time datetime="' . $published . '" class="mb-2 text-muted&...


1

The "question mark data" = token that prevents caching issues after Joomla updates. When you update Joomla to a higher version, its CSS and/or JavaScript can be changed. Visitors that visited your website before will load it from their cache and not the new files from the site. If you really don't want that, you could change the 'version' => '...


2

Been a while since I used repeatable form fields (deprecated and subform fields should be used instead), but if I rightly remember, the repeatable form fields response format was a little different. It grouped each column in an array rather than each row. So what you'll need to do is define a function to group the values by key: function groupByKey($array) {...


3

It is always good advice to take a usable back up of your site before making any changes to important aspects like PHP. Having said that I haven't had any issues switching back to previous versions of PHP over the years when needed. The most likely issues you will encounter moving from PHP 5 to PHP 7.x will be whether all the required PHP extensions are ...


2

It's how Repeatable field stores its data. Pick a field to iterate over and use its key to access value of another field: foreach ($carousel_images['carouselimage'] as $key => $image) { // do something clever for each of the images '<img src="' . $image .'"><p>' . $carousel_images['carouselcaption'][$key] . '</p>'; } ...


0

Use Joomla\CMS\Application\WebApplication::getDocument(). In your code you're already doing this with $app->getDocument().


4

JControllerLegacy::getInstance() caches the first controller instance so you're actually getting an instance of your component's controller rather than Content controller. You can skip the controller and get the model directly instead: JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel'); $model = JModelLegacy::...


Top 50 recent answers are included