Skip to content

Instantly share code, notes, and snippets.

View phproberto's full-sized avatar

Roberto Segura phproberto

View GitHub Profile
@phproberto
phproberto / README.md
Last active December 25, 2015 06:39
Ubuntu: JS minify compatible for bootstrap files using + Joomla bootstrap minify example

This uses UglifyJS to create minified files.

Install node:

# python-software-properties is needed to use add-apt-repository
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
@phproberto
phproberto / sample.php
Last active December 28, 2015 08:39
Load jQuery for Joomla! 2.5 - 3.x
<?php
if (version_compare(JVERSION, '3.0', '<'))
{
if (JFactory::getApplication()->get('jquery') !== true)
{
// Load jQuery in no conflict mode with B/C support
JHtml::script(JUri::root() . 'templates/joostrap/js/jquery.min.js');
JHtml::script(JUri::root() . 'templates/joostrap/js/jquery-migrate.min.js');
JHtml::script(JUri::root() . 'templates/joostrap/js/jquery-noconflict.js');
@phproberto
phproberto / default.php
Created March 11, 2014 23:29
Sample email this page link
<?php $url = JUri::getInstance()->toString(); ?>
<a class="email" title="Email a friend" href="mailto:?subject=Interesting information&body=I thought you might find this information interesting: <?php echo $url; ?>">Email</a>
@phproberto
phproberto / asset.php
Created May 21, 2014 00:11
Sample Joomla asset helper
<?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;
@phproberto
phproberto / post-receive
Created July 11, 2014 06:52
Base post-receive bash hook for web deploy
#!/bin/bash
cd /var/www/mywebfolder.com
unset GIT_DIR
git fetch origin
git reset --hard origin/master
@phproberto
phproberto / default.xml
Created October 29, 2014 09:48
Sample Joomla logout & redirect view
<?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 / params.php
Last active August 29, 2015 14:14
Disable scripts inside joomla template
<?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 / sample.php
Created June 5, 2015 10:12
Joomla: Get available values for a fieldsattach multiple selector
<?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 / templates\protostar\html\layouts\com_content\article\image.php
Created October 23, 2015 02:03
Joomla layouts to generate thumbnails on the fly
<?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;
<?php
$app = JFactory::getApplication();
$newId = $app->input->getInt('mid');
$myId = $app->getUserStateFromRequest('phproberto.mid', 'mid');
if ($newId)
{
$url = JUri::getInstance();