Startnet - Web Design in Wimbledon

Startnet - Web Design in Wimbledon

Joomla, Wordpress, Magento and Web Tips Blog

Restore a magento database

Tuesday, 20 December 2011 14:59

To restore a .sql file backup without constraint checking, simply add the following statements at the beginning of your .sql file:

SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT;
SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;
SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;
SET NAMES utf8;
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;

At the end of the file, add the statements required to turn on constraint checking again:

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT;
SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS;
SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION;
SET SQL_NOTES=@OLD_SQL_NOTES;

then use bigdump.php to upload/install the file to Mysql.
   

Joomla password reset MD5's

Monday, 12 December 2011 13:03

password = "MD5 hash of password"
------------------------------------------------------
admin = 21232f297a57a5a743894a0e4a801fc3
secret = 5ebe2294ecd0e0f08eab7690d2a6ee69
OU812 = 7441de5382cf4fecbaa9a8c538e76783

Use in the jos_users table.
   

Image mapping made easy at image-maps.com

Monday, 22 August 2011 15:26

Had to create some image maps for a client. These usually take ages to work out using the area tags and stuff like that,
BUT discovered http://www.image-maps.com/ and it turns out to be a remarkably good website and a useful tool.

Just upload the image you want to add the image map to, pick the points on the image you want (they are displayed for you). You can even add the links.

Then click Save and go throught to the HTML / CSS code view.

Very good stuff guys, saved me a lot of time, thanks.

 

   

Get xscreensaver folder to work on xubuntu eee PC

Thursday, 28 July 2011 14:06

Installed xbuntu 7.10 r3 to my old 701 EEE PC, as I just want to use it as a photo frame.

Has everything built-in. Except had huge trouble finding how to change the screen saver directory to a different one.

After several hours, found out how to do it:

edit your ~/.xscreensaver file and add:

imageDirectory:/home/username/whatever

Here are the options for the .xscreensaver file http://linux.die.net/man/1/xscreensaver-getimage

if you want the screensaver to fill the entire screen you have to add the clip option, hence :

sudo su -

vi /usr/share/applications/glslideshow.desktop

(all the screensaver command files are in that directory). Change the Exec line:

Exec=glslideshow -root -clip

or Exec=glslideshow -root -duration 15 -pan 15 -fade 5 -titles

command line options for glslideshow is here: http://linuxcommand.org/man_pages/glslideshow1.html


 

   

Adding jquery innerfade to vslider on Wordpress

Wednesday, 06 July 2011 10:34

wordpress_small

Was getting a bit frustrated with the very good vSlider plugin for Wordpress. it's a very good and simple image slider plugin for Wordpress, with a nice interface for adding images and changing the sliding effects, BUT there's one problem, it doesn't do proper image fading. The nearest you can get is to set the square sizes to 1, but it still isn't quite the image fading I wanted. This is because it uses the 'coinslider' jquery script, which doesn't have a proper image fader, I wanted something like the well known innerfade uses.  So, having a look, I discovered it was relatively easy to add the famous innerfade.js jquery script to it and hey presto! it works. Just copy jquery.innerfade.js to the js folder, cut/paste the following two sections in vslider.php and there you have it.

Lines 45-66 of the vslider.php file found in /wp-content/plugins/vslider/js

function vslider_head_scripts() {
wp_enqueue_script ('jquery');
wp_enqueue_script('vslider', WP_CONTENT_URL.'/plugins/vslider/js/vslider.js', $deps = array('jquery'));
wp_enqueue_script('innerfade', WP_CONTENT_URL.'/plugins/vslider/js/jquery.innerfade.js', $deps = array('jquery'));

}
function vslider_head() { $options = get_option('vslider_options'); ?>
<!-- Start vSlider options -->
<script type="text/javascript">var $jq = jQuery.noConflict(); $jq(document).ready(function() {
$eft='';
if ($eft!='fader') { // use coinslider
$jq('#vslider').coinslider({ width: , height: , spw: , sph: , delay: , sDelay: , opacity: , titleSpeed: , effect: '<?php echo $options["effect"]; ?>', navigation: , links : , hoverPause: });
} // end of coinslider js
else { // use innerfade instead
$jq('#vslider').wrapInner('<ul id="vslider" />');
$jq('#vslider a').wrap('<li>');    
$jq('ul#vslider').unwrap();
$jq('#vslider').innerfade({ speed: 'slow', timeout: , type: 'sequence', containerheight: 'px' });
}
}); </script>
<style type="text/css" media="screen">
ul#vslider { list-style-type:none; }

AND change Line 194 to this:

<p><?php _e("Effect", 'vslider'); ?>:<select name="vslider_options[effect]"><option value="" >all combined</option><option value="random" >random</option><option value="swirl" >swirl</option><option value="rain" >rain</option><option value="straight" >straight</option><option value="fader" <?php selected('fader', $options['effect']); ?>>fader</option></select></p>

 

OR TO MAKE THIS EASY just download the files here:

jquery.innerfade.js
vslider.php

copy vslider.js to the wp-content/plugins/vslider/ folder and innerfade.js to the /wp-content/plugins/vslider/js folder

thanks,

James

   

Joomla, Magento and MySQL Coding Tips

Wednesday, 19 May 2010 11:30

Here are some Joomla and MySQL Coding Tips and Tricks. You may find these useful for a variety of common tasks when programming Joomla templates and modules / components.

 


Joomla Base URL in index.php


echo $this->baseurl ?>/includes/js/captify.tiny.js"
<img src="/images/stories/spinach_logo.png">


Joomla default menu (homepage), view, option variables in index.php

// if a section set background body type for background image
$menu = &JSite::getMenu();

// echo the menu item name
echo $menu->getActive()->name;
echo $menu->getActive()->id; // id number


if ( JRequest::getCmd('view') === "section" ) {
$db = &JFactory::getDBO();
$temp   = JRequest::getString('id');
$temp   = explode(':', $temp);           
$id   = $temp[0];

$db->setQuery('SELECT title FROM #__sections WHERE id='.$id);  
$sname=$db->loadResult();
$sname=str_replace(" ","_",$sname);
$sname=str_replace("'","",$sname);
echo "_".strtolower($sname);
}

elseif ( ($menu->getActive() == $menu->getDefault()) || ( JRequest::getCmd('view') === "frontpage" ) ) {
echo "_homepage";
}



Joomla countModules function

<?php if ($this->countModules( 'user1' )) : ?>

<div id="imageFlick">
<jdoc:include type="modules" name="slider_image" style="xhtml" />
</div>


Joomla index.php PHP copyright

echo "© Startnet Ltd ".date("Y");


<jdoc:include type="modules" name="footer_menu" style="xhtml" />


Joomla index.php component (main text)

<jdoc:include type="component" />


Joomla error reporting FULL in configuration.php

var $error_reporting = '-1'; // NONE

var $error_reporting = '2048'; // FULL


Joomla component/module XML parameter element types eg. calendar, textfield, categories path

/libraries/joomla/html/parameter/element

http://docs.joomla.org/Tutorial:Template_parameters


Joomla MYSQL loadResult

global $database;
 
$sql = 'SELECT title FROM #__categories';
$database->setQuery( $sql );
echo $database->loadResult();
$sql = "SELECT * FROM #__categories WHERE title=$title";
$database->setQuery( $sql );
$category = $database->loadRow();
print_r( $category );


$sql = 'SELECT * FROM #__users';
$database->setQuery( $sql );
$user = NULL;
$database->loadObject( $user );
echo "Name: $user->name\n";
echo "Username: $user->username\n";

$sql = 'SELECT * FROM #__categories';
$database->setQuery( $sql );
$rows = $database->loadObjectList();
foreach ( $rows as $row ) {
echo "$row->title: $row->description\n";
}


LINK TO MORE DATABASE FUNCTIONS

PHP mysql_connect for SELECT

<?php
$con = mysql_connect("localhost","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("database", $con);

$result = mysql_query("SELECT * FROM jos_menu");

while($row = mysql_fetch_array($result))
{
//  echo $row['id'] . " " . $row['menutype']. " " . $row['name'];
//  echo "<br />";

print "<pre>";

print_r($row);

print "</pre>";

}



mysql_close($con);
?>


PHP mysql_connect for UPDATE

mysql_select_db("database", $con);

$result = mysql_query("ALTER TABLE jos_acajoom_subscribers ADD interested_in varchar(200); ");

if (!$result) {
die('Invalid query: ' . mysql_error());
}

mysql_close($con)


Illegal characters in MYSQLdump solution:

use php or command line to export mysql database as latin1 :
<?php
exec("mysqldump --default-character-set=latin1 -uUSERNAME -pPASSWORD DATABASE > DATABASE.sql");
?>

open in editor and Find/Replace latin1 to utf8

then import using web interface or command line.

 


Fix the Magento Database import error : Can't create table 'api_session.frm' (errno: 150).

the problem is caused by having ENGINE=InnoDB in lines for foreign keys.

edit the file and do a find/replace for "ENGINE=InnoDB" to remove them.

Make sure to drop / create the database, so you start afresh and re-import the data. Should all work then.

 


Magento admin page xxx.com/index.php/admin gives 404 error.

SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

 


Magento - display product attributes in category list page

Say you've added 'brand' as an attribute and added it to the Default attribute set (make sure the attribute is visible in the frontend). Then add this:

From http://www.magentocommerce.com/boards/viewthread/19215/

<?php
echo $this->htmlEscape($_product->getData('brand'));        
?>