Skip to content

Instantly share code, notes, and snippets.

Roberto Segura phproberto

Block or report user

Report or block phproberto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@phproberto
phproberto / blog.php
Last active Feb 15, 2018
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 Nov 27, 2017
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 Oct 27, 2017
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();
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 Jun 5, 2015
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 Aug 29, 2015
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 Oct 29, 2014
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 Jul 11, 2014
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
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;
You can’t perform that action at this time.