Posts

Showing posts from January, 2022

Simple JavaScript clock

Although this code can easily be found on the Internet, we still write a simple JavaScript clock Clock: < div id = " clock " > </ div > < script > function clock ( ) { let date = new Date ( ) , hours = date . getHours ( ) , minutes = date . getMinutes ( ) , seconds = date . getSeconds ( ) ; if ( hours < 10 ) hours = '0' + hours ; if ( minutes < 10 ) minutes = '0' + minutes ; if ( seconds < 10 ) seconds = '0' + seconds ; let time = hours + ':' + minutes + ':' + seconds ; document . getElementById ( 'clock' ) . innerText = time ; setTimeout ( ( ) => { clock ( ) ; } , 1000 ) ; } clock ( ) ; </ script >

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

Tabs jQuery plugin

Tabs are a fairly common element. There are various implementations of this element on the Internet. But often the tabs are overloaded with code filled with effects that are unlikely to be needed in ordinary tasks. Therefore, it was decided to write simple tabs, so to speak, “for myself”. Maybe they will be useful to someone else. Tabs can be downloaded from GitHub . Tabs do not have any effects, but directly fulfill their purpose - hide and display. HTML <!--Installation--> < head > < script src = " /jquery.js " > </ script > < script src = " /simpletabs.js " > </ script > </ head > <!-- //--> < div class = " tabsblock " > < div class = " headertabs " > < div class = " nametab actheadtab " > Tab 1 </ div > < div class = " nametab " > Tab 2 </ div > < div class = " nametab

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 http://tools.dynamicdrive.com/password/

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