Hot answers tagged

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::...


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 ...


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 ...


3

You have the instruction in your code, but commented. The query setLimit() function requires two parameters: $limit: the number of records to return, and $offset: the first record you want to return, zero-based. This is the signature of the function: public function setLimit($limit = 0, $offset = 0) Please take notice that the parameter order is opposite ...


3

Your original coding attempt is repeatedly overwriting the $dataPoints variable inside of the loop -- this is why you only see the last iteration's data. To create the desired multidimensional array directly from the query's result set, here is the way to use column aliases and Joomla's query building syntax. $db = JFactory::getDbo(); $query = $db->...


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

It is doubtful it may work; and even if it did, you risk other issues. Components often use constants and loaders that would not work outside the component itself, such as JPATH_COMPONENT. I see the main risk in the assets, which will be created by Joomla referencing your calling component (the social login component) instead of the called component (Easy ...


2

I consider this a very valuable question that does not have good write-ups/tutorials yet in Joomla documents (we should create one). I am trying to give here some workable info on this. Loading Form Fields using Joomla implemented show-on conditions is not for loading dynamically changing checkboxes, list or combo field's values and fields. For loading Form ...


2

To start with you can create a override of the list page, your first image, by going into the Administrator Template you are using on your site, by default the drop down will display Site so you need to change it to Administrator. Select the Tab Create Override and then going to com_users at the bottom of the Components list, expanding the selection and ...


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) {...


2

After much experimentation I'm pretty sure it's not possible to achieve this without Javascript, but I did manage it this way: I added this code to the menu's main php file (about line 53 in the default.php override): if ($item!=parent) { $class .= ' single'; } Then in the template.js added this: let single = [...document....


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>'; } ...


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; ?>


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' => '...


1

I would suggest that you contact the creators of Easy Profile Pro and ask them if they are able to create similar functionality as provided in the products that you mention. They may be in the best position, as it is likely their code will need to be modified, if you decide to pay someone to write the code to provide the functionality. I need to add the ...


1

I finally solved this problem by simply removing the headers from the request. var form = document.getElementById('myform'), formData = new FormData(form); var xhr = new XMLHttpRequest(); xhr.open('GET', window.location.pathname+'?option=com_mycomp&task=view.mytask&id=567&'+Joomla.getOptions('csrf.token')+'=1', true); xhr....


1

Although the other answer works, it's not very efficient. Instead everything but $query->values() call can be done outside the loop. This way multiple rows are inserted with a single database query: $query = $db->getQuery(true) ->insert($db->quoteName('#__table_name_')) ->columns($db->quoteName($columns)); foreach($arrayDecodedJson ...


1

The solution was simple. Put $query = $db->getQuery(true);, inside the foreach loop. Make an array in order to put inside the arrays values like : $values = array($db->quote($value['value1']),$db->quote($value['value2']),$db->quote($value['value3']),$db->quote($value['value4']) Then you make the query like so inside the foreach loop: ...


1

If you implement the code from my earlier code, then you only need to write a dynamic $having array to generate the correct HAVING clause. I must note that your current coding attempt is not stable/secure. You are receiving user-supplied data from $_POST and feeding it directly into your raw sql. This means that there are no validating or sanitising steps ...


1

I found the above problem solved after using Helix Ultimate 2 Beta 2 Quickstart Package (https://github.com/JoomShaper/helix-ultimate/releases/download/v2.0.0-beta.2/helixultimate_2_beta2_quickstart.zip). Here are the steps that I followed: Download the Helix Ultimate Quickstart Package at https://github.com/JoomShaper/helix-ultimate/releases/tag/v2.0.0-...


1

First of all you may well be able to use the Joomla SQL Form Field for your Job Title field, instead of having to write a custom field. To make the Technologies dropdown dependent upon the Job Title field you may be able to use the showon attribute as described in Enabling showon to work in list options. In your Technologies custom field you'd have to select ...


1

I am not aware of any ready made multi-user portfolio extension for Joomla and you may need a combination of extensions together with the core Joomla features to achieve all the functionality you require. If you want photographers to be able to manage photo albums from the front-end of the website, this limits your choices quite a bit as there are only a few ...


1

If you only see 3 out of 5 payment methods then probably there is a restriction that prevents those methods from being displayed. Do you use another extension for integration with a payment provider that might need a bit of extra configuration? If I see it correctly then the 3 methods displayed are the ones that don't need anything special to work so I would ...


1

As I suggested in my comment, building a plugin for this may be an alternative solution worth pursuing. In a system plugin, simply add code similar to the example below to intercept any calls. Rest assured the code below was not tested on animals. intercept onAfterRoute() ensure your code should really run there, as an example: exclude administrator ...


1

Since the value of $this->item->extra_fields is either an array or null, you don't need to check if it "is set" with !empty() or isset(); a truthy value check is all that is required. if ($this->item->params->get('itemExtraFields') && $this->item->extra_fields) { By writing $this->item->extra_fields (without any ...


1

Thanks a lot, James Shaver, I had no idea that such a PHP repository as packagist.org existed (tried Pear and Pecl and various Google searches). I found the Wikimedia/XMP-reader (Ver. 0.7) and installed and ran it according to instructions. Works great - see below. Also read your PDF and I learnt that the XMP Data block cannot be trusted to be authorative. ...


1

You'll probably want to look at something like Composer to install libraries in your component or plugin. Simple search: https://packagist.org/?query=iptc%20exif%20xmp First one found: https://packagist.org/packages/wikimedia/xmp-reader README Reader for XMP data containing properties relevant to images, written in PHP. Install composer require wikimedia/xmp-...


1

When running Joomla from git clone you can use build/stubGenerator.php script. It will generate stubs.php file in Joomla's root directory.


1

If I understand your problem correctly then you just have to change the first few lines of your original code because you do not just want look for the user ID from the database (user table) but you also need to define the user ID from the particular article's URL. So try it with using the following at the beginning of your code: $articleUrl = \Joomla\CMS\...


Only top voted, non community-wiki answers of a minimum length are eligible