Posts

Showing posts from January, 2022

Joomla DB Queries

Consider two types of queries into the Joomla database by its own means. The code was written for CMS version 3. Perhaps in the versions below it will also work, but it was not checked. For clarity, the examples will be wrapped in a function. The first is when we need to get multiple values. function getAllCategoryesId ( ) { $db = JFactory : : getDBO ( ) ; $query = "SELECT `category_id` FROM `#__jshopping_categories` WHERE `category_publish` = 1" ; $db - > setQuery ( $query ) ; $categoriesId = $db - > loadObjectList ( ) ; $ids = array ( ) ; foreach ( $categoriesId as $catId ) { array_push ( $ids , $catId - > category_id ) ; } return $ids ; } In this case, we received a list of identifiers of published categories as an array. But there is a situation when we need to get one specific value. For this fit a slightly different design. Also we will wrap everything in a function. function getDescriptionCategory ( ) { ...

Closing a site with .htaccess

The .htaccess file performs many different functions. This is an apache configuration file. Consider how to set a password for access to the site using .htaccess . This may be needed at design time or as an additional security tool. To store the password (or passwords) from the directory, you need to create another file. Usually it is called .htpasswd , but you can call it differently. Put this file must be in the root of the site or above Sample entry in .htaccess AuthName "Authentication required" AuthType Basic AuthUserFile /home/yourdir/.htpasswd require user yourlogin Set the password for yourlogin user in the .htpasswd file yourlogin:Mk5aMaDxjJch2 The link to generate passwords https://stringutils.online/htpasswd

Adding fields to the ZOO category

This article is about the ZOO component for Joomla CMS . First of all consider adding a simple text field to the right side of the admin panel category ZOO . 1. Open media/zoo/applications/blog/aplication.xml and after the line < param name = " image " type = " zooimage " label = " Image " description = " Choose a category image. " /> add: < param name = " ourname " type = " text " label = " Our field name " description = " Our tip " /> 2. Output in category template media/zoo/applications/blog/templates/default/category.php <?php echo $this - > category - > getParams ( ) - > get ( 'content.ourname' ) ; ?> ourname is our unique name. You can add a picture field ZOO instead of a text field. Сhange type="text" to type="zooimage". We get src of the picture in the output. Adding fields to the main area of the ZOO category admin panel Wh...

How to create a custom jQuery plugin

The convenience of the jQuery plugin is that you can use the same code several times for different objects. In this case, copy-paste code is not needed. In addition, you can change the behavior of the plugin with different parameters. To write your jQuery plugin, you need to expand the $.fn object In general, it looks like this: $ . fn . MyPlugin = function ( ) { //plugin code } We write a plugin that will add a paragraph with the class "paragraph" after the selected object by clicking on it. By default we will set the red color of the text of our paragraph. ( $ => { $ . fn . myPlugin = function ( options ) { let settings = $ . extend ( { //set default parameters color : 'red' } , options ) ; //write the logic of our plugin $ ( this ) . on ( 'click' , function ( ) { let par = '<p class="paragraph">An added paragraph</p>' ; ...