Skip to content

Instantly share code, notes, and snippets.

@2dpi
2dpi / gist:b7969592177bfaca51e4
Created Jun 16, 2015
JOOMLA - Add Style Declaration
View gist:b7969592177bfaca51e4
<?php if (!empty($attribs->select_banner_image)) {
$style = 'html {
background-image: url('.$attribs->select_banner_image.') !important;
background-size: contain;
background-repeat: no-repeat;
background-position: center top;
}';
$doc->addStyleDeclaration( $style );
} ?>
@2dpi
2dpi / gist:6a82181a4b223be7ecb4
Created Jun 10, 2014
PHP: array reset key values and filter empty
View gist:6a82181a4b223be7ecb4
<?php
// RESET KEY VALUES TO START FORM 0 AND REMOVE EMPTY/NULL ENTRIES
$array =array_values(array_filter($array));
?>
@2dpi
2dpi / gist:bb5a06812bab0cb11b1b
Created May 20, 2014
SQL: copy column value from one table to another
View gist:bb5a06812bab0cb11b1b
UPDATE table1 INNER JOIN table2 ON table1.field_name = table2.field_name SET table1.field_name = table2.field_name
@2dpi
2dpi / gist:a540527a64f9f0093392
Created May 13, 2014
JOOMLA: truncate text blocks over the specified character limit (ie. word trim)
View gist:a540527a64f9f0093392
<?php
///////////////////////////////////////////////////////////////////////////////////
// ADD TEXT TO BE TRIMMED, SET TRIM LENGTH IN CHARACTERS, BREAK WORD, STRIP HTML //
// http://api.joomla.org/cms-3/classes/JHtmlString.html //
///////////////////////////////////////////////////////////////////////////////////
echo JHTML::_('string.truncate', $text, $length, true, false );
?>
@2dpi
2dpi / W3_Labels
Last active Aug 29, 2015
HTML: W3 Lables
View W3_Labels
<!--
LABEL > set style (warning, success, info, errro, add)
EXPAND with float, inline, outline_, grad, in_ or out_ etc..
-->
<span class="inline in_tighter outline_round label_warning">Label</span>
<span class="inline in_tighter outline_round label_success">Label</span>
<span class="inline in_tighter outline_round label_info">Label</span>
<span class="inline in_tighter outline_round label_error">Label</span>
<span class="inline in_tighter outline_round label_add">Label</span>
@2dpi
2dpi / gist:5890113
Created Jun 29, 2013
SQL: joomla tag title output
View gist:5890113
<?php
// Initialiase variables.
$db = JFactory::getDbo();
foreach ($item->getValue('art_tags') as $key => $tag) {
if ($key >= 0) {
// Use following line in a model.
$query.$key = $db->getQuery(true);
// Prepare query.
$query.$key->select('u.id,u.parent_id,u.path,u.title');
@2dpi
2dpi / gist:5012040
Last active Dec 14, 2015
JOOMLA: date format
View gist:5012040
<?php
// change default date format
// http://docs.joomla.org/How_do_you_change_the_date_format%3F
// http://nl3.php.net/manual/en/function.date.php
echo JHtml::_('date',$yourDateVariable, JText::_('j F, Y'));
// will output 22 Month, 2013
?>
View php_date_format.php
<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone
// http://nl3.php.net/manual/en/function.date.php
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
@2dpi
2dpi / gist:4492396
Created Jan 9, 2013
JAVASCRIPT: print web page button/link
View gist:4492396
// JAVASCRIPT - PRINT PAGE
// =======================
// http://javascript.about.com/library/blprint.htm
// Add a link to locally hosted file
// <link rel=alternate media=print href="printversion.pdf">
window.print();return false;
// HTML link
// <a href="#" onclick="window.print();return false;">Print This Page</a>
@2dpi
2dpi / gist:4425610
Created Jan 1, 2013
SEBLOD: adding related article fields to search
View gist:4425610
SEBLOD - ADDING RELATED ARTICLE FIELDS TO SEARCH
================================================
http://www.seblod.com/support/forum/Content-Types--Forms/29682-SOLVED-Relate-product-to-manufacturer-be-able-to-search-products-by-manufacturers-fields.html#29784
- CCK (* required core field)
(1) Variation = Hidden
(2) Live = Default | Live value = yourContentType (for related article)
(3) Match = Exact
(4) Stage = 1st