Skip to content

Instantly share code, notes, and snippets.

Avatar

Roberto Segura phproberto

View GitHub Profile
@phproberto
phproberto / blog.php
Last active February 15, 2018 10:56
Joomla: Use custom field for layout in category view
View blog.php
<?php
/**
* @package Joomla.Site
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
@phproberto
phproberto / plg_system_test.php
Last active November 27, 2017 21:20
Experimento de cambio del formato de RSS para Ciro
View plg_system_test.php
<?php
/**
* The update check and notification email code is triggered after the page has fully rendered.
*
* @return void
*/
public function onAfterRender()
{
$app = JFactory::getApplication();
@phproberto
phproberto / explanation.md
Created October 27, 2017 11:54
Dummy router for Jooma Blank Component causing no 404 pages
View explanation.md

Reproduce the issue:

  • You have Blank Component assigned to the home page of your Joomla! site.
  • When you manually enter a wrong url you don't get any 404 error. Your site redirects all the non-existing urls to the home page.

Explanation

Joomla redirects all the non-existing urls to the router of the component assigned as home page. Blank component does not have a router so you just get redirected to the home page.

This is a dummy empty router that will force an empty option be set if the component router is called to parse any url. This should not break anything because Blank Component cannot work without a menu item assigned to it. It only ensures that the router does not parse any url.

View example.php
<?php
$app = JFactory::getApplication();
$newId = $app->input->getInt('mid');
$myId = $app->getUserStateFromRequest('phproberto.mid', 'mid');
if ($newId)
{
$url = JUri::getInstance();
@phproberto
phproberto / templates\protostar\html\layouts\com_content\article\image.php
Created October 23, 2015 02:03
Joomla layouts to generate thumbnails on the fly
View templates\protostar\html\layouts\com_content\article\image.php
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
@phproberto
phproberto / sample.php
Created June 5, 2015 10:12
Joomla: Get available values for a fieldsattach multiple selector
View sample.php
<?php
$db = JFactory::getDbo();
// Get the available offices
$offices = array();
$officeFieldId = 5;
$query = $db->getQuery(true)
->select('field.extras')
->from('#__fieldsattach AS field')
@phproberto
phproberto / params.php
Last active August 29, 2015 14:14
Disable scripts inside joomla template
View params.php
<?php
$doc = JFactory::getDocument();
// Supposes you have a template setting with name loadJquery
$loadJquery = $this->params->get('loadJquery', 1);
if ($loadJquery)
{
$removeJs = array(
'/jquery.min.js',
@phproberto
phproberto / default.xml
Created October 29, 2014 09:48
Sample Joomla logout & redirect view
View default.xml
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_MYCOMPONENT_TITLE_VIEW_LOGOUT" option="View">
<message>
<![CDATA[COM_MYCOMPONENT_TITLE_VIEW_LOGOUT_DESC]]>
</message>
</layout>
<fields name="params">
<fieldset name="basic">
<field
@phproberto
phproberto / post-receive
Created July 11, 2014 06:52
Base post-receive bash hook for web deploy
View post-receive
#!/bin/bash
cd /var/www/mywebfolder.com
unset GIT_DIR
git fetch origin
git reset --hard origin/master
@phproberto
phproberto / asset.php
Created May 21, 2014 00:11
Sample Joomla asset helper
View asset.php
<?php
/**
* @package MyExtension.Library
* @subpackage Helper
*
* @copyright Copyright (C) 2014 Roberto Segura. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('_JEXEC') or die;