Thursday, November 26, 2009

Create a fluid Joomla module using template override on mod_newsflash

Logic to calculate module width based on number of items to be dispalyed. In this example below this logic assumes PARENT DIV width is 980 pixels wide and module width will be adjusted accordingly to fit inside a 980 pixel element floating left so they look like they are in a straight line.

Wednesday, November 25, 2009

Auto Clear pre text in input box

Place the code below in your scripts.js file:



And in your input box code be sure to add:

Wednesday, September 16, 2009

Find and Replace data in MySQL using phpmyadmin

in phpmyadmin run this SQL query

update table_name set field_name = replace(field_name, ‘Old Data’, ‘New Data’)


table_name is the name of table in database

field_name is the name of the column in your table

Find and Replace in MySQL

in phpmyadmin run this SQL query

update table_name set field_name = replace(field_name, ‘Old Data’, ‘New Data’)

Thursday, August 27, 2009

How to find absolute path using php


Create a file called path.php with the following code:

echo realpath(dirname(__FILE__));

Thursday, August 13, 2009

Read More itemid Hack on Joomla 1.0

Goto: components/com_content/content.html.php

Example: So if readmore link on home page is picking up Itemid=42 and you want to force it into another interior Itemid then:

At around line 1768

Change function ReadMore a link to:

Monday, August 10, 2009

Correcting the 1px OFF Center Aligned Background Bug

The bug appears when trying to align even numbered width backgrounds, with an odd numbered width browser viewport (or vice versa).....read more

http://www.sohtanaka.com/web-design/1px-background-alignment-bug/

Tuesday, August 04, 2009

sh404sef and Virtuemart pagination issue

Insert this in component/com_sh404sef/sef_ext/com_virtuemart.php just after the function definitions (eg: if (!function_exists('vmSefGetProductName')) i.e. at around line 95):

// Detect where a menu item with a non-standard Itemid is being processed and simulate a VM internal 'menu' item to facilitate pagination
global $sess;
if( !isset($sess) ) {
require_once( JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'virtuemart_parser.php' );
}
$vm_Itemid = $sess->getShopItemid();
// Check whether the Itemid is the usual value for a VM menu item
if( $Itemid != $vm_Itemid ) {
// The URL is based on a menu item other than the standard VM menu item (usually the home page)
// VM always uses the standard VM Itemid value in pagination URLs and so this URL will be updated to
// use the standard Itemid and to incorporate any menu item parameters, in case pagination is appropriate.
$menu = & shRouter::shGetMenu();
$menuItem = $menu->getItem( $Itemid );
if( $menuItem ) {
// Get the menu parameter set
$menuparams =& new JParameter( $menuItem->params );
// Replicate the logic used by VM to assess whether a browse or product detail page required
$tmp_product_id = $menuparams->get( 'product_id' );
$tmp_category_id = $menuparams->get( 'category_id' );
// Get the page name and remove '.php', if present
$tmp_page = preg_replace('/\.php/', '', strtolower($menuparams->get( 'page' )));
if( !empty($tmp_product_id) ) {
$default_page = 'shop.product_details';
} else if( !empty($tmp_category_id) ) {
$default_page = 'shop.browse';
} else {
$default_page = '';
}
$tmp_page = empty($tmp_page) ? $default_page : $tmp_page;
// Check whether the menu item is a browse page or product detail page (other pages are excluded
$allowed_pages = array(
'shop.browse',
'shop.product_details',
);
if( in_array($tmp_page, $allowed_pages) ) {
// Clear down the unwanted get vars from the $shGETVars array
$required_params = array(
'option',
'lang',
);
global $shGETVars;
foreach( $shGETVars as $param ) {
if( !in_array($param, $required_params) ) {
unset($$param);
unset($shGETVars[$param]);
}
}
// Reset the Itemid
$Itemid = $vm_Itemid;
shAddToGETVarsList( 'Itemid', $Itemid );

// Replicate the logic used by VM to include specific parameter values
if( !empty($tmp_product_id) ) {
$product_id = $tmp_product_id;
shAddToGETVarsList( 'product_id', $product_id );
} else if( !empty($tmp_category_id) ) {
$category_id = $tmp_category_id;
shAddToGETVarsList( 'category_id', $category_id );
}
$tmp_flypage = $menuparams->get('flypage');
if( ( !empty($tmp_product_id) || !empty($tmp_category_id) ) && !empty($tmp_flypage) ) {
$flypage = $tmp_flypage;
shAddToGETVarsList( 'flypage', $flypage );
}
$page = $tmp_page;
shAddToGETVarsList( 'page', $page );
// Process any other menu parameters not already processed
$params = $menuparams->toArray();
// Exclude system parameters and those already processed
$excluded_params = array(
'product_id',
'category_id',
'flypage',
'page',
'page_title',
'show_page_title',
'pageclass_sfx',
'menu_image',
'secure',
);
// Process each parameter
foreach( $params as $param => $value ) {
if( !in_array($param, $excluded_params) && $value != '' ) { // Note empty() is not used here because zero is valid
$$param = $value;
shAddToGETVarsList( $param, $value );
shRemoveFromGETVarsList( $param );
}
}
}
}
}

// Set the page number for browse pages, if not already set
if( !isset($limitstart) || !isset($limit) ) {
$my_page = explode('.', $page);
$pagename = isset($my_page[1]) ? $my_page[1] : '';
if( $pagename == 'browse' ) {
global $vm_mainframe, $mosConfig_list_limit;
if( !isset($limitstart) ) {
// VM stores a different default limitstart value for each different browse page. That value must be identified so that the URL
// is created for the expected page
// Store the 'current value' of limitstart so that it can be restored later
$save_limitstart = vmRequest::getVar('limitstart');
// Setting the 'current value' to null allows the stored value (if any) to be retrieved without it being overwritten by a
// 'current value' that is usually not applicable to that particular browse page
vmRequest::setVar( 'limitstart', null );
// Force a consistent value for category_id when empty
$category_id = empty($category_id) ? 0 : $category_id;
$limitstart = (int)$vm_mainframe->getUserStateFromRequest( "view{$keyword}{$category_id}{$pagename}limitstart", 'limitstart', 0 );
shAddToGETVarsList( 'limitstart', $limitstart );
// Restore the original 'current value' of limitstart
vmRequest::setVar( 'limitstart', $save_limitstart );
}
if( !isset($limit) ) {
// No need to save and restore values here because VM only uses one value globally
$limit = (int)$vm_mainframe->getUserStateFromRequest( "viewlistlimit{$page}", 'limit', $mosConfig_list_limit );
shAddToGETVarsList( 'limit', $limit );
}
}
}

// Ensure that $limitstart is a multiple of $limit (this can occur if $limit was changed since $limitstart was set)
if( isset($limitstart) && $limit > 0 ) {
$limitstart = floor($limitstart/$limit)*$limit;
shAddToGETVarsList( 'limitstart', $limitstart );
}

In backend settings:

Look for Virtuemart configuration in plugins page
- Select to YES the option that says “Using Items per page drop-down list”
- Save your settings
- Purge SEF urls

Wednesday, July 01, 2009

Increase Username field for Silent Registration in Virtuemart. Allows for long email addresses to be used as a username

FOR Joomla 1.0.x & Virtuemart 1.10.x only

use phpMyAdmin to modify jos_users

Change Type/Length of username field from 25 to 255

Edit File:

administrator\components\com_virtuemart\classes\ps_shopper.php

Line: 174

Change Code:

$silent_username = substr( str_replace( '-', '_', $d['email'] ), 0, 25 );

To:

$silent_username = substr( str_replace( '-', '_', $d['email'] ), 0, 255 );


Editincludes/joomla.php file

find the lines

// check that username is not greater than 25 characters
$username = $this->username;
if ( strlen($username) > 25 ) {
$this->username = substr( $username, 0, 25 );

To:

$username = $this->username;
if ( strlen($username) > 25 ) {
$this->username = substr( $username, 0, 25 );

To Increase in com_registration

EDIT:

administrator/components/com_users/admin.users.html.php

Replace <> with []

[input type="text" name="username" class="inputbox" size="40" value="username; ?>" maxlength="25" /]

to

[input type="text" name="username" class="inputbox" size="40" value="username; ?>" maxlength="255" /]

EDIT:

line 123

components/com_registration/registration.html.php

Browser specific CSS hacks

Safari 3 Specific Hack:


@media screen and (-webkit-min-device-pixel-ratio:0) {
/* Safari 3.0 and Opera 9 rules here */
}

eg:


@media screen and (-webkit-min-device-pixel-ratio:0) {
body { background-color: blue; }
}


Firefox 3 HACK: example:

html>/**/body #con_left, x:-moz-any-link, x:default {
padding: 104px 0px 0px 1px;
}

Lightbox Modal Effect

-in your scripts.js goes:

SqueezeBox.initialize({});
$$('a.lightbox').each(function(el) {
el.addEvent('click', function(e) {
new Event(e).stop();
SqueezeBox.fromElement(el);
});
});
OR if no domready

window.addEvent('domready', function() {
SqueezeBox.initialize({});
$$('a.lightbox').each(function(el) {
el.addEvent('click', function(e) {
new Event(e).stop();
SqueezeBox.fromElement(el);
});
});
});



-in template your index.php, to call Joomla's Mootool engine...before html goes:

JHTML::_('behavior.modal');

-In article ADD class="lightbox" example:

NOTE Replace [ ] with <>

[a class="lightbox" href="images/stories/image.jpg"][img class="noborder" src="images/stories/small_image.jpg" border="0" alt="Image" /][/a]

How to add and validate extra field in contact form (com_contact)

- component/com_contact/views/contact/tmpl/default_form.php
- component/com_contact/views/contact/controller.php

TO MAKE A FIELD VALIDATE ADD class="inputbox required" to input field thats reads as:

Repalce [] with <> below

[input type="text" name="name" id="contact_name" class="inputbox required" value=""]

===============================================

Example: to catch Form post PHONE FIELD

add

$phone = JRequest::getVar( 'phone', '', 'post' );

to line 116 in controller.php

add

.$phone.

to line 178 which reads

$body = $prefix."\n"."Name: ".$name."\n"."Phone: ".$phone.' <'.$email.'>'."\r\n\r\n".stripslashes($body);


To ADD into the default_form.php ADD (remember to replace [] with <> tags below)

[label for="contact_phone"] [?php echo JText::_( 'Phone' );?]:[/label]
[input type="text" name="phone" id="contact_phone" size="30" class="inputbox" value="" /]

Wednesday, January 21, 2009

Custom CSS Class in TinyMCE

edit: plugins\editors\tinymce.php

line 229 IF CONDITION: if($content_css) should read:

if($content_css)
            {
                $file_path = JPATH_SITE .'/templates/'. $template .'/css/';
                if ( !file_exists( $file_path .DS. 'editor.css' ) ) {
                    $template = 'template_folder_name_here';
                }

                $content_css = 'content_css : "' . JURI::root() .'templates/'. $template . '/css/editor.css",';
            } else {
                $content_css = '';
            }
        }

Allow Javascript in TinyMCE editor

In TinyMCE plugin settings/parameters

set 

Extended Valid Elements to

script[language|type]

Reset Virtuemart Invoice Number

delete all records from:

jos_vm_orders
jos_vm_order_history
jos_vm_order_item
jos_vm_order_payment
jos_vm_order_user_info

goto  jos_vm_orders  then click on Operations tab, then change auto increment value to whatever you want your Invoice number to start with

Tuesday, January 20, 2009

Auto Expand Sections/Categories in Extended Menu Module for Joomla 1.5

The solution for this is altering some files from the module:

modules/mod_exmenu-j15/exmenu/loader/autoexpandedmenu.menuloader.class.php

Change lines 177 to 192 from:

Code:

switch($menuNode->type) {
case 'content_category':
case 'content_blog_category':
case 'content_archive_category':
if ($contentItemVisible) {
$this->categoryMenuNodeList[] =& $menuNode;
}
break;
case 'content_section':
case 'content_blog_section':
case 'content_archive_section':
if (($categoryVisible) || ($contentItemVisible)) {
$this->sectionMenuNodeList[] =& $menuNode;
}
break;
}



to:

Code:

$tipoMenu = $this->getRawUrlParameter($menuNode->link, 'view');
switch($tipoMenu) {
case 'category':
if ($contentItemVisible) {
$this->categoryMenuNodeList[] =& $menuNode;
}
break;
case 'section':
if (($categoryVisible) || ($contentItemVisible)) {
$this->sectionMenuNodeList[] =& $menuNode;
}
break;
}



This will do the work to generate the links, but Extended Menu won't give then the proper classes when they are active, so it's needed to change one more file:

modules/mod_exmenu-j15/exmenu/loader/menuloader.class.php

Change lines 297 to 303 from:

Code:

switch($task) {
case 'view':
case 'edit':
case 'cancel':
$result = $id;
break;
}



to:

Code:

$result = $id;

Virtuemart hack - Auto Expand all Virtuemart Categories

This method works for display type: LINK LIST

edit 

administrator/components/com_virtuemart/classes/ps_product_category.php

disable code in line 686 and line 810

$allowed = false;

to

//$allowed = false;

For Dtree:

In components/com_virtuemart/js/vm_dtree.php change line 38 from

$openAll = 'false';

to

$openAll = 'true';