Skip to content

Instantly share code, notes, and snippets.

View alexandreelise's full-sized avatar
👋
Hello Super Joomlers!

Mr Alexandre J-S William ELISÉ alexandreelise

👋
Hello Super Joomlers!
View GitHub Profile

One-liner to use plausible.io Web Analytics on your Joomla Website

Joomla\CMS\Factory::getApplication()->getDocument()->getWebAssetManager()->registerAndUseScript('plausible-io', 'https://plausible.io/js/script.js', [], ['defer' => true, 'data-domain' => \Joomla\CMS\Uri\Uri::getInstance()->getHost()], []);

WHY

Scratched my own itch. Thought it might be useful to you too.

@alexandreelise
alexandreelise / error.php
Last active May 13, 2023 14:44
Handle Joomla 404 errors gracefully in 5 lines of code: Fr: Redirection erreur 404 vers un article Joomla en 5 lignes de code / En: Redirect incoming 404 errors to custom Joomla article in 5 lines of code
<?php
/** Redirection vers article personnalisé */
if ($this->error->getCode() == 404) {
header(sprintf('Location: %s', \Joomla\CMS\Router\Route::_('index.php?option=com_content&view=article&id=64', false, \Joomla\CMS\Router\Route::TLS_FORCE, true)));
exit(0);
}
@alexandreelise
alexandreelise / create-joomla-article-from-streamed-csv-with-raw-php-using-joomla4x-api.php
Last active October 8, 2022 15:58
Create an article in Joomla from streamed csv with raw php using Joomla! 4.x Web Services Api
<?php
declare(strict_types=1);
/*
YOUR ATTENTION PLEASE. THE NEW PLACE FOR THIS CODE IS : https://github.com/alexandreelise/j4x-api-examples
*/
/**
@alexandreelise
alexandreelise / plg_fields_articles_layout_title.php
Created October 2, 2022 19:33
Quick fix on line 29 to prevent error from happening when using this plugin with Joomla! 4.x Webservices Api. Fix made for one of my Super Joomler friends: Custom King.
<?php
/**
* @package Articles Field
* @version 3.9.0
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://regularlabs.com
* @copyright Copyright © 2022 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
@alexandreelise
alexandreelise / plg_content_responsive.php
Created October 2, 2022 19:21
Quick fix on line 31 to prevent error when using it with Joomla! Webservices Api
<?php
/**
* @package ttc-freebies.plugin-responsive-images
*
* @copyright Copyright (C) 2017 Dimitrios Grammatikogiannis. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') || die;
use Joomla\CMS\Plugin\CMSPlugin;
@alexandreelise
alexandreelise / SmokeTest.php
Created October 2, 2022 04:18
SmokeTest using PhpUnit and Joomla Framework Http package
<?php
namespace AlexApi\Tests;
use Generator;
use Joomla\Http\HttpFactory;
use Joomla\Uri\Uri;
use PHPUnit\Framework\TestCase;
class SmokeTest extends TestCase
@alexandreelise
alexandreelise / customasset.php
Last active February 5, 2022 15:29
Load Custom Assets In Joomla! Core mod_custom using this layout override
<?php
declare(strict_types=1);
/**
* Custom Assets
*
* @version 1.0.0
* @package Customasset
* @author Alexandre ELISÉ <contact@alexapi.cloud>
* @copyright (c) 2009-2022 . Alexandre ELISÉ . Tous droits réservés.
@alexandreelise
alexandreelise / fancysubform.php
Created December 9, 2021 01:06
How to render a subform custom field manually by using php in Joomla! 4.0.x
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Subform
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @contributor Alexandre ELISÉ <contact@alexapi.cloud> Modified version on 2021-12-08
* @description The content of this file needs to be copied in
* YOUR_JOOMLA_WEBSITE_ROOT/templates/cassiopeia/html/layouts/com_fields/field/fancysubform.php
@alexandreelise
alexandreelise / user.css
Last active November 16, 2021 15:07
Create full-width component area in Joomla! 4. It my implementation of an idea coming from my Super Joomler friend Marc DECHÈVRE
@supports (display: grid) {
body:not(.has-sidebar-left) .site-grid .container-component {
grid-column-start:span 6;
}
@media (min-width : 992px) {
/* Must add page-has-full-width in menu item custom css class for page */
body.site.page-has-full-width .site-grid {
grid-template-areas : ". banner banner banner banner ." ". top-a top-a top-a top-a ." ". top-b top-b top-b top-b ." "comp comp comp comp comp comp" ". side-l side-l side-r side-r ." ". bot-a bot-a bot-a bot-a ." ". bot-b bot-b bot-b bot-b .";
}
@alexandreelise
alexandreelise / README.md
Last active May 29, 2023 21:19
Render All Joomla! 4 Standard Form Fields

j4xall

Render All Joomla! 4 Standard Form Fields using a article layout override. To make it work, you can put this the j4xall.php file at this location:


JPATH_ROOT/templates/cassopeia/html/com_content/article/j4xall.php