JLV-Solutions JLV-Solutions
  • Home
  • Blog
  • Products
    • Eventlist
    • CB export
    • Tracks
      • Download
      • Support forum
      • Demo
      • Documentation
      • Tracks custom fields
      • Individual and Team modules
      • Tracks upcoming events ticker
  • Contact us

Blog

Implementing views hierarchy in Joomla router for nice sef urls

Empty
  •  Print 
  • Email
Details
Julien Vonthron
Development
25 April 2020
Hits: 6825

Introduced in Joomla 3.4, the new component router tries to solve in a modern way the issue of building nice sef urls with Joomla.

You can find a basic explanation of how to implement on the official Joomla Documention. However, as I was working on implementing it for Tracks, I ran into some issues with the way to build urls in a nice hierarchical way. 

Read more: Implementing views hierarchy in Joomla router for nice sef urls

How to override Joomla JHtml functions

Empty
  •  Print 
  • Email
Details
Julien Vonthron
Development
21 March 2017
Hits: 9320

There are many pages out there explaining how to override Joomla Layout, or even full classes, but it's also possible to overrides functions called by JHtml::_() function.

To do that, all you need to do, is to place the function to override in a system plugin, and to register the function override in a onAfterInitialise() function.

here is an example (that forces the date picker widget to use Monday as the first day of the week):

<?php
/**
* @package Mypackage
* @subpackage Plugins
*
* @license GNU General Public License version 2 or later, see LICENSE.
*/

// No direct access
defined('_JEXEC') or die('Restricted access');

// Import library dependencies
jimport('joomla.plugin.plugin');

use Joomla\Utilities\ArrayHelper;

/**
* Jhtml override
*
* @since 1.0.0
*/
class PlgSystemJhtmloverride extends JPlugin
{
public function onAfterInitialise()
{
JHtml::register('calendar', array('PlgSystemJhtmloverride', 'calendar'));
}

/**
* Displays a calendar control field
*
* @param string $value The date value
* @param string $name The name of the text field
* @param string $id The id of the text field
* @param string $format The date format
* @param mixed $attribs Additional HTML attributes
*
* @return string HTML markup for a calendar field
*
* @since 1.5
*/
public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
{
static $done;

if ($done === null)
{
$done = array();
}

$readonly = isset($attribs['readonly']) && $attribs['readonly'] == 'readonly';
$disabled = isset($attribs['disabled']) && $attribs['disabled'] == 'disabled';

if (is_array($attribs))
{
$attribs['class'] = isset($attribs['class']) ? $attribs['class'] : 'input-medium';
$attribs['class'] = trim($attribs['class'] . ' hasTooltip');

$attribs = ArrayHelper::toString($attribs);
}

JHtml::_('bootstrap.tooltip');

// Format value when not nulldate ('0000-00-00 00:00:00'), otherwise blank it as it would result in 1970-01-01.
if ($value && $value != JFactory::getDbo()->getNullDate() && strtotime($value) !== false)
{
$tz = date_default_timezone_get();
date_default_timezone_set('UTC');
$inputvalue = strftime($format, strtotime($value));
date_default_timezone_set($tz);
}
else
{
$inputvalue = '';
}

// Load the calendar behavior
JHtml::_('behavior.calendar');

// Only display the triggers once for each control.
if (!in_array($id, $done))
{
$document = JFactory::getDocument();
$document
->addScriptDeclaration(
'jQuery(document).ready(function($) {Calendar.setup({
// Id of the input field
inputField: "' . $id . '",
// Format of the input field
ifFormat: "' . $format . '",
// Trigger for the calendar (button ID)
button: "' . $id . '_img",
// Alignment (defaults to "Bl")
align: "Tl",
singleClick: true,
firstDay: 1
});});'
);
$done[] = $id;
}

// Hide button using inline styles for readonly/disabled fields
$btn_style = ($readonly || $disabled) ? ' style="display:none;"' : '';
$div_class = (!$readonly && !$disabled) ? ' class="input-append"' : '';

return '<div' . $div_class . '>TEST'
. '<input type="text" title="' . ($inputvalue ? JHtml::_('date', $value, null, null) : '')
. '" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($inputvalue, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />'
. '<button type="button" class="btn" id="' . $id . '_img"' . $btn_style . '><span class="icon-calendar"></span></button>'
. '</div>';
}
}

 

Integrating React to Joomla

Empty
  •  Print 
  • Email
Details
Julien Vonthron
Development
27 January 2017
Hits: 17185

As i was searching for an example of React to Joomla, i stumbled onto this github repository

I cloned locally, but i needed some effort to make it work, as there was no instruction.

So, after i finally managed that, i decided to make it easy for other people to try it out, so i pushed my modifications to my own clone here.

Enjoy !

Company information:

JLV Solutions
1 avenue de l'Orangerie
06600 Antibes
FRANCE
SIREN : 505 593 378
SIRET : 505 593 378 00014
 
  • Contact us
  • Mentions légales
  • Politique de confidentialité
  • Terms and conditions
Bootstrap is a front-end framework of Twitter, Inc. Code licensed under MIT License. Font Awesome font licensed under SIL OFL 1.1.