By default, many web browsers will open files like .js and other text-based files in a new tab. However, if you want users to be able to download these files directly, such as you might with .zip files, you can easily achieve this by adding the download attribute to your …
Read More »Useful solutions
How to open html pages without .html
If your site uses links like http://domain.com/testpage.html and http://domain.com/demo.html, and you want them to open like http://domain.com/testpage and http://domain.com/demo, you can use this solution. Go through FTP or a File Manager to the folder with the site files. Open file .htaccess and add the following code: RewriteEngine on RewriteBase / …
Read More »Display the date + a few days from the current one
The task in short: you need to make the delivery date + 5 days from the current date in PHP, with the output of the month in the genitive case in RU. But you can ignore custom edits for that language version. The method with date( ‘d FY’ ); is …
Read More »Open expanded block by link in accorderon/spoiler/toggle
The case can be like this – for example, from the main page you need to place links to an internal page where a list of questions and answers is placed. On the inner page, the link should expand the answer to a specific question. The solution is here: HTML …
Read More »Different content for More Lang language versions in a template using a shortcode
I like More Lang plugin because there are no duplicate pages and posts for other language versions in the admin panel. But I had a problem – for the banners on the home page (which are embedded in the theme) there was no way to change the texts dynamically, depending …
Read More »How to add 301 redirect to https for Yii2 without .htaccess
I’ve tested different redirect options for .htaccess, but sites keep giving “redirected you too many times” error. Here is the working code to solve the problem. In the file /config/web.php you need to find: 'bootstrap' => [ 'log', 'app\components\Bootstrap', ], and place below: 'on beforeRequest' => function ($event) { if(!Yii::$app->request->isSecureConnection){ …
Read More »How to find changed files in console
Relevant for Linux, macOS. This article lists commands that help you find files that have changed over a certain period. 1. Find all modified files in the current folder in order of freshness of changes. The most recent will be on top: find ./c -type f -printf '%TY-%Tm-%Td %TT %p\n' …
Read More »Fixed panel that can only be closed once
The solution was for the message “We use cookies to enhance your experience in our web site. By visiting it, you agree our Cookies Policy.” It is important that the panel does not reappear after closing/accepting the agreement. Here is the HTML, CSS, JS code to implement the panel on …
Read More »Popup image on click without href
A very elegant solution, with which the image will not be wrapped in <a href=””></a>, image will float on click to the center of the screen and will be able to close both on the top cross and on a click on a translucent background. Image code: <div class="image__wrapper"> <img …
Read More »Show and hide block with js
Few examples for showing a block on button click. Example 1: easy to use <script type="text/javascript"> function openlink(id){ display = document.getElementById(id).style.display; if(display=='none'){ document.getElementById(id).style.display='block'; }else{ document.getElementById(id).style.display='none'; } } </script> The block will be opened by clicking on the link: <a href="#" onclick="openlink('mylink'); return false">Open the link</a> Content will be shown when …
Read More »