Skip to content

Instantly share code, notes, and snippets.

<?php
$app = JFactory::getApplication();
$layout = $app->input->getCmd('layout');
if ($layout != 'blog') {
<jdoc:include type="modules" name="sidebar" />
}
OR you check the view:
@uglyeoin
uglyeoin / Akeeba Backup Cron for Siteground
Last active November 19, 2018 15:18
Akeeba Backup Cron Job for Siteground.
## Where profile 2 is my external backup e.g. Amazon S3.
/usr/local/php70/bin/php-cli /home/ACCOUNTNAME/public_html/cli/akeeba-backup.php --profile=2
<?php
$moduleName = $module->module;
<div class="<?php echo $moduleName; ?>">
//module stuff
</div>
?>
@uglyeoin
uglyeoin / Get Menu Item ID.php
Last active November 7, 2018 14:00
Get the active menu item ID
<?php
$app = JFactory::getApplication(); // Access the Application Object
$menu = $app->getMenu(); // Load the JMenuSite Object
$active = $menu->getActive(); // Load the Active Menu Item as an stdClass Object
echo $active->id; // echo the output
highlight_string("<?php\n\$active =\n" . var_export($active, true) . ";\n?>"); // show all options
@uglyeoin
uglyeoin / Error decoding JSON data: Control character error, possibly incorrectly encoded
Created June 26, 2018 12:14
Error decoding JSON data: Control character error, possibly incorrectly encoded
OK, that means there's some broken JSON in the params of one of your elements.
Unfortunately, the only way to get some clue as to which one is to modify some Joomla core code.
Edit the file:
./libraries/vendor/joomla/registry/src/Format/Json.php
... and around line 72 will be ...
@uglyeoin
uglyeoin / Modules media location dynamically.php
Last active November 7, 2018 14:00
Modules media location dynamically
<?php
// Add a stylesheet
$mediaUrl = 'media/' . $module->module;
$cssName = 'general.css';
if (file_exists($mediaUrl . '/css/' . $cssName) && filesize($mediaUrl . '/css/' . $cssName) > 0)
{
$document = JFactory::getDocument();
$document->addStyleSheetVersion($mediaUrl . '/css/' . $cssName, array('version' => 'auto'));
}
/* This only shows to admins. Consequently you either need to be logged in or have shared sessions turned on to see anything */
use Joomla\CMS\Factory;
<?php
$user = Factory::getUser();
$isroot = $user->authorise('core.admin');
if($isroot) {
highlight_string("<?php\n\$params =\n" . var_export($params, true) . ";\n?>");
}
<?php echo "<pre>" . print_r($params, true) . "</pre>"; ?>
@uglyeoin
uglyeoin / set email to HTML
Last active May 22, 2018 19:54
Joomla HTML email
// Set the email to HTML
JFactory::getMailer()->addRecipient()->addSender()->setSubject()->setBody()->isHtml();