Hot answers tagged

3

I would have preferred to just suggest some touch ups to your snippet, but there is too much for me to address in your answer as a comment and I'd rather explain fully. Instead, I'll post this new answer which will review and clean up your assumed-working coding attempt for the benefit of you and future researchers. You are declaring $images = json_decode($...


3

Firstly, I'll just point out that behavior.tooltip which is based on the JHtmlBehavior class, is old and deprecated, so I will base my answer on the newer Bootstrap tooltips. Take the following HTML markup: <a href="#" title="The text for the tooltip">Some link</a> You can then utilise the JHtmlBootstrap class method, like so: JHtml::_('...


2

I don't see set() in the JTable docs. You also need to remember to re-encode the full column value before storing. The following is an untested snippet. $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select(db->qn("item_id")) ->from($db->qn("#__fields_values")); // build all of the non-changing clauses for ...


2

I've solved it this way... 1) Create an override folder (if not existing) in your template folder for the Contact Form add-on. Copy the content from <joomla_root_path>/components/com_sppagebuilder/addons/ajax_contact to <joomla_root_path>/templates/sppagebuilder/addons/ajax_contact 2) In the admin.php file add the following code after '...


2

✔️ The use of $jinput->get() with INT parameter to sanitise the incoming data for security and stability. 💡 To maintain a consistent variable naming convention in accordance with Joomla's official recommendation: Regular Variables and Class Properties Regular variables follow the same conventions as functions. This will allow your script to ...


2

Use JVERSION constant. It holds the value returned by Joomla\CMS\Version::getShortVersion().


2

Hard to say without seeing the complete code but my guess is you don't initialize the application and the language file in question does not get loaded. You can load it manually: $language->load('lib_joomla', JPATH_ADMINISTRATOR);


2

Create a simple ajax plugin that handles your user login logic and returns a message for your users. The following 2 files should be zipped together and installed on your site. userlogin.php <?php defined('_JEXEC') or die; // Import library dependencies jimport('joomla.plugin.plugin'); class plgAjaxUserLogin extends JPlugin{ function ...


2

I think I have a good idea where the error is. You are using $this->getFileName() to get the files original name, then you mutate the filename using normalize(). At this point you have a new file name, but the system doesn't realise that this is the filename to be used forevermore. Basically, you will either need to rename the file in your file system ...


2

Personally I wouldn't use a .css.php file. The following assumes you WON'T be supporting Internet Explorer and I will be answering your question about CSS filters. The grid/masonry can be asked as a separate question. So, let's say you want to set a CSS filter (grayscale) and the percentage is set dynamically. You firstly want to have the following CSS file (...


2

Here are the official Joomla! Docs for anyone else looking in the future: https://docs.joomla.org/How_do_I_use_Gmail_as_my_mail_server%3F How do I use Gmail as my mail server? If you have a working Gmail account you can use Gmail as your mail server by setting it in the global configuration. On the server tab set the following: Mailer: SMTP SMTP Host: smtp....


2

I think you are looking for the rawvalue property of the field object /* Rearrange Fields for use */ foreach($this->item->jcfields as $jcfield){ $this->item->jcFields[$jcfield->name] = $jcfield; } $absolute_path_to_image = JUri::base() . $this->item->jcFields['your-field-name']->rawvalue;


1

The easiest way to do what you are trying to accomplish is with template overrides, not plugin events (we don't call them "hooks" in Joomla). Ideally, you'd need to make a template override for com_users' login view and the mod_login module to make sure that both places where a user can log in are covered. The reason I'm not recommending a plugin ...


1

As @Sharky said, it seems like your SQLSRV extension isn't enabled. You can manually activate it by changing your php.ini file, enabling this extension and downloading the drivers. PHP Documentation says: The SQLSRV extension is enabled by adding appropriate DLL file to your PHP extension directory and the corresponding entry to the php.ini file. The SQLSRV ...


1

You can definitely delete rows from multiple tables in a single query, but Joomla doesn't offer a query-building technique to accommodate this. If you absolutely demand that query builder methods must be used, then you'll need to conduct some "surgery" (which isn't very pretty) on the generated query before executing it -- see https://joomla....


1

Why don't you do it in 2 steps? I would do something like the following code. As you can see I use name spacing (since Joomla 3.8), used quoteName the table + field names and added a try/catch block. use Joomla\CMS\Factory; public function delete_codes() { $id = $this->input->getInt('id'); $query = $db->getQuery(true) ->delete($db->...


1

Don't use JUri for fetching local files. It returns the web address of your site. Fetching files over HTTP is extremely slow compared to fetching files locally. Use one of JPATH constants to get a local filesystem path, e.g.: $json = JPATH_BASE . '/modules/mod_kou_stack_exchange/media/js/sites.json'; $json = file_get_contents($json); https://docs.joomla....


1

Use the filepath: JUri::base() . '/modules/mod_kou_stack_exchange/media/js/sites.json' The filesystem equivalent of, eg. /public_html/yoursite/modules/... or /htdocs/yoursite/modules/... where Joomla is installed in yoursite directory.


1

That sort of thing is completely in the control of the template designer; Joomla doesn't care how that's set. Not being familiar what template you're using, it's hard for me to tell precisely how it's done. From the site's markup, it looks like it's in a module (would probably be a custom HTML module). I'd look for one of those called something like "logo" ...


1

The problem has nothing to do with the cache being disabled. It is that the plugin is using a different cachebase setting than the cache that saved the data. The cache that saved the data used the site cache folder located at /cache, while the plugin is using the cache folder located at /administrator/cache. It doesn't see the data because it's looking in ...


1

I had some time to check this problem but I was not able to duplicate your issue. I created a short sample caching test in one of my layout files like: $myCache = \JFactory::getCache('my_cache'); $myCache->setCaching(1); $dataToCache = "<h2>this works now</h2>"; $myCache->store($data = $dataToCache, $id = 'yep1', $group = '...


1

Overall this is coming along well! You just need to change in your view.html.php $this->item = $this->get('Item'); to $this->items = $this->get('Items'); This call will get translated by the view get function into a call getItems in the model JModelList, which will then run the query you supplied in your model getListQuery. You're already ...


1

If I'm understanding you right, I think you want to have in your form definition xml file <fieldset name="fields-1" label="label-1" description="desc 1"> ... Then in your layout file do $fieldset = $this->form->getFieldsets(); and then you can do echo $fieldset['fields-1']->label; // outputs "label-1" echo $fieldset['fields-1']->...


1

A few pointers to offer: When checking the existence of a substring in a string, the PHP documentation advises: Note: If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead. So it is best practice to use if (strpos($result->href, 'com_content') !== false) { ...


1

This error was caused by the AutoTweet NG Light RSS module. As I could see the RSS feed in my browser I was reasonably sure the 403 forbidden error was a red herring. I tested this by trying Joomla! Core Mod_feed (feed display), this worked. I can only assume some sort of server configuration error due to cURL but I do not control the server so this is ...


1

The solution to my question. I think is valid: <?php $images = json_decode($item->images); ?> <span itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> <link itemprop="url" href="<?php // Create new DOMDocument object. $dom = new DOMDOcument; // Load article text into DOMDocument. $dom->loadHTML($item->...


1

As your problem is not really with Joomla but with Docker and PHP this is probably not the best area to be asking about this issue. A quick google search with 'stackexchange docker php' came up a few potential causes for your issue from some compression libraries not install by default to instruction for how you need to set up your Docker environment.


1

Session data is stored as Registry. Use keys separated by a dot to access nested properties. $session->set('array.key', 'value');


1

You have posted snippets that are using two separate means of updating the form. The javascript-leveraging snippet is updating the form AFTER the form elements have already been generated. This means that the standard form for all users is adjusted at the last moment to apply the cookie values to the fields for that specific user -- seems like the right ...


1

For one, you are declaring: $inputCookie->set('rsformdatacountry', $_POST['form']['country']); This means that the rsformdatacountry cookie value is a string (not an array). This is appropriate assuming that your form is not allowing multiple selections. When you call it, use: $activeCountry = $inputCookie->get('rsformdatacountry', '', 'string'); ...


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