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
@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 / add-custom-fields-to-core-modules-j3x.php
Created November 26, 2019 09:23
Add custom fields to core modules in Joomla! 3
<?php
defined('_JEXEC') or die;
?>
<div class="latestnews">
<ul class="list-group list-group-flush">
<?php foreach ($list as $item) : $image = json_decode($item->images); ?>
<?php
// most important part
// context:
// for articles: com_content.article
@alexandreelise
alexandreelise / joomla-3-user-login-by-code.php
Created December 2, 2019 19:30
Joomla! 3 user login programmatically using a simple php snippet
/**
* @var bool $result_login true on successful login, false otherwise
*/
$result_login = Factory::getApplication()->login(
[
'username' => 'example',
'password' => 'mysupersecretpassword'
],
[
'remember' => true,
@alexandreelise
alexandreelise / modularsqlexample.xml
Created January 5, 2020 20:30
Example Joomla! component with separated install SQL files running in order presented in this manifest file
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.9" method="upgrade" client="administrator">
<name>com_modularsqlexample</name>
<author>example</author>
<creationDate>0000-00-00</creationDate>
<copyright>(C) example. All rights reserved.</copyright>
<license>http://www.gnu.org/copyleft/gpl.html</license>
<authorEmail>modularsql@example.com</authorEmail>
<authorUrl>example.com</authorUrl>
<version>1.0.0</version>
@alexandreelise
alexandreelise / htmlhelper-select-options-with-empty-default.php
Created September 26, 2020 01:03
Code snippet for HTMLHelper select options with empty default value
<label for="demo">Demo</label>
<select id="demo" name="demo">
<?php array_unshift($this->myExampleOptionsArray, null); ?>
<?php echo HTMLHelper::_('select.options', $this->myExampleOptionsArray, 'value', 'text', $this->selectedOptionValue ?? '');?>
</select>
@alexandreelise
alexandreelise / all.php
Last active April 12, 2022 13:20
Tiny php script to show all available JFormFields in Joomla! 3
<?php
/**
* @package all
* @author Alexandre ELISÉ <contact@alexandre-elise.fr>
* @link https://alexandre-elise.fr
* @copyright (c) 2020 . Alexandre ELISÉ . Tous droits réservés.
* @license GPL-2.0-and-later GNU General Public License v2.0 or later
* Created Date : 19/07/2020
* Created Time : 16:04
*/
@alexandreelise
alexandreelise / aej.php
Last active March 11, 2022 12:53
generate random json data structure using a cryptographically secure prng
<?php
declare(strict_types=1);
/**
* A.E Json Jammer (cryptographically secure prng to generate random json data structure)
*
* @package aej
* @author Alexandre ELISÉ <contact@alexapi.cloud>
* @link https://alexapi.cloud
* @copyright (c) 2020 - present. Alexandre ELISÉ. All rights reserved.
* @license MIT
@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