Thursday, April 18, 2013

How to Hide Selected K2 Extra Fields from the front end?

K2 component (getk2.org) for Joomla 2.5 and Joomla 3.0 is still a very useful extension. K2 was built as a complete replacement of the default article system in Joomla! but many people use it in a surprising way, like the people's profiles in the online Marriage Agency.
K2 can keep the information in articles about thousands of women/men of different age, appearance and occupation. For personal characteristics you can use K2 Extra Fields so you and your users will be able to sort people according to certain characteristics (age, eye color), like the products in the store.
Sometimes you might want to hide the selected custom fields, but only the front view of the article. And then what? Unfortunately, component K2 did not foresee such a possibility. If anyone is a programmer can modify the code, but I wanted to use a simple solution, non-invasive method.

CSS Pseudo-classes  Can Help You with K2 Extra Fields

Depending on which field you want to hide in order to select one of the solutions:
  • :first-child - this pseudo-class matches an element only if it's the first child element of its parent element.
  • :nth-child(N) - matches elements on the basis of their positions within a parent element’s list of child elements.
  • :nth-last-child(N) - matches elements on the basis of their positions within a parent element’s list of child elements.

Now edit your template.css file or K2.css file and add only one line of CSS code at the bottom:

div.itemExtraFields ul li:first-child { display:none; }


It will hide first element of list, in our case, the first field.
This example selector will match the first three rows of Extra Field list:

div.itemExtraFields ul li:nth-child(-n+3) { display:none; }

This solution has "only one" defect - browser support - this pseudo-classes are currently not supported in Internet Explorer 8 and in older versions.

Tuesday, April 2, 2013

Import a large MySQL database over SSH

By default, most PHP uploaders limit the import file size of a MySQL database to 50MB. You may not always be able to change the limit yourself (depending upon your host) so the alternative way to import the database is to use SSH.

Start by uploading the .sql file onto the server using your regular FTP/FTPS/SFTP client.
Log into the server using SSH and navigate to the directory where your .sql file is.
Run this command:
mysql -p -u username database_name < file.sql
Notes:
The -p will prompt for your database password.
Replace username, database and file.sql with their appropriate values.
--------------------------------------------------------------------------------

If you are accessing via cPanel root use following command :
root $: cd /home
root $: ls
root $: cd /home/username of domain


Monday, April 1, 2013

How to Add ReCaptcha in K2 Joomla

The new version of Joomla - 2.5 has a captcha form element built in - which is great.  However, if you install K2 (2.5.6) this also uses the same ReCaptcha element.  Unless you get the settings just right the two will conflict in strange ways.  In order for the system to work you need to
  1. Disable the Captcha -ReCaptcha component in the Joomla Comonent Manager
  2. Go to the User Manager and then to the Options (Users Configuration) and set Captcha to be "none selected"
  3. Go to the K2 configuration and enable Captcha and enter your public and private keys.
If you don't do this, then both captcha's will be used but only one will be displayed (the K2 one I think) and you will get error messages similar to this:
"The words you typed did not match the ones displayed. Please try again."
Or if you disable just the K2 Captcha then you get this error message:
Empty solution not allowed.


 -------------------------------------------------------------------------------------------------


I have resolved the problem
You don't have to disable anything, just to get the Captcha - ReCaptcha plugin working on K2 comment you have to follow these steps:

1 - ON www.google.com/recaptcha Go to
- USE reCAPTCHA ON YOUR SITE
- ADD Gmail account if you don't have, or log in if you have.
- Go MY ACCOUNT -> + Add a New Site
- Create a reCAPTCHA key -> ADD your Domain -> Create a Key.
- Copy (Public Key and then you will copy the Private Key)

2 - On your admin panel go to:
- Component -> K2 -> Parameters -> Comments-> Active reCaptcha -> Yes.
- Go to Component -> K2 -> Parameters -> Advanced -> Anti-spam.
- Past the two Key that you have from Google. (Public and Private Key)
-> Refresh you site and you got it ^_^

IF YOU STILL DON'T HAVE THE CAPTCHA WORKING:
Make sure you have enabled the K2 plugin and Comments on the Category options.
That should be resolving your problem.

- IF, IF that is still not working:
- Go to your site
- Click " F12 " on Google Chrom / Control+F12 (Firebugs, Firefox)
- Refresh your web site
- If you have a JavaScript errors try to find what is your problems and solutions.
- Last thing if you don't have any JS problem, You should re-install joomla xD

That is all


If there is still problem do following step:
----------------------------------------
Hi there; it seems jQuery is not well loaded in your site.
Do the following:
1. Go to plugin, and ensure that K2 system plugin is enabled (i.e on the back end, go to Extensions, select plugin manager, check out k2 system plugin and ensure it is enabled).
2. Ensure that you setup correctly the jQuery handling options under K2 parameters. All you need to do is go to admin back end, click under components, go to K2 component. Once it is, click on k2 parameters. Check under 'layout & views'. Check jQuery library handling; set it to load v.1.8.2 local; also do the same under Backend jQuery & jQuery UI handling; set it to local copy.

Ensure your k2 comments are enabled and alas, everything will work.

IF THE ABOVE FAILS -- I AM DEAD SURE IT WONT; DO THE FOLLOWING:

Make sure that there is no other javascript error on your page preventing reCAPTCHA from operating. Have in mind that you only need one copy of jQuery on your site. K2 namespaces jQuery with $K2.

Instead of the following:

$(document).ready ....

You can use the following:

$K2(document).ready ....




Cheers!

Friday, March 29, 2013

Move Virtual Box Virtual Machines to New Server/Location

Step 1: Locate and move the Virtual Machine
You will be looking for a .vdi file. The location of this file will depend upon the host platform. On Linux host, the file will be found in ~/VirtualBox VMs.

On Mac Host, the file will be found in Go>Home>VirtualBox VMs

Within that directory, you will find sub-directories of all your virtual machines. Within the virtual machine directory in question, you will find the .vdi file — that is, the file that must be moved to the new host. Copy that file to an external or shared drive and then copy it onto the new host (the location doesn’t matter).


Step 2: Create a new virtual machine
The process of creating the new virtual machine will be the same as if you were creating a standard virtual machine until you get to the Virtual Hard Disk creation screen (Figure-1). You will select Use Existing Hard Disk, click the folder icon, navigate to the newly copied .vdi file, select the file in question, and then click Next.



Step 3: Copy All MAC addressess
When you move your VM to new location it is good to copy your network card MAC address from Old Virtual Box and past into new Virtual Box virtual machine, For doing this you will not face any complicated network connectivity issue after starting your machine.

Follow the step below:

1..Select newly created Virtual machine in virtual box.
2..Click on setting
3..Click on Network
4..Delete existing MAC address and Past the same mac address as it was in old Virtual Box VM.
5..Do it with all network Cards.
6..Also make same setting for network like "NAT or Bridge" etc.


------------------------------------------------------------------------------------------------------


Since your mac address have changed you no longer have an interface called eth0, this name is reserved for an interface with the "old" mac-address. The "new" interface should have the next free name (eg. ethN).


To see all the interfaces on the machine you can use this command:

ifconfig -a

If you want to reset the name reservations for network interfaces you can remove the file

/etc/udev/rules.d/70-persistent-net.rules

and restart the machine (or remove/insert the device, though this is not possible in this case).

Alternatively you can change the interface-name that you have configured to what ever the new one is called by changing all occurences of the old name with the new one in the file


/etc/network/interfaces

Saturday, March 23, 2013

How to mount Folder into the folder from another Drive folder in Windows 7

A symbolic link is a reference to another file or folder on your drive. Symbolic links or short symlinks are originally a linux-only feature, but since 2000 Windows supports them too. The difference between symbolic links and junction points is that a symbolic link can also point to a file or remote SMB network path (which means that you can also create cross-system symlinks, which could come in handy in a network if you don’t want to copy all of the files). Let’s say you want to launch a game or application from another PC, normally, you’d have to copy it to your own PC, but with symlinks you can launch it as long as you are connected to the other PC.

 Create & Remove Junction Points in Windows 7

Download Junction v1.05 for Windows
Copy it somewhere e.g. to \windows\system32\
You can then create junction points via the command line:
CD: C:\Windows\system32
junction.exe “c:\new folder” “d:\path\real folder”
Remove junction points:
junction.exe -d “c:\new folder”




Friday, March 22, 2013

How do you mount a directory as a drive in Windows 7?

How do you mount a directory as a drive in Windows 7?
---------------------------------------------------------
If you have touched DOS before, you might still remember what this old school command subst

is all about. It is a command used for substituting local paths on physical and logical

drives, known as virtual drives. For example, if you want to have a logical drive N: mapped

to a local folder on your computer, say c:\temp, you can simply use the following command to

make it.

    subst N: c:\temp

If you want to have it permanent, there is a really nasty and hidden trick, creating a new

key in the registry.

You have to go to

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices

and there create a key named with the drive letter you want, colon included
(N: in our example) and with this value:

\??\c:\\windows


you can obviously change c: and windows for whatever folder you want, but remember to double the backslash after the unit letter, because it won’t work with a single backslash.
Reboot and enjoy your new N: :)

To Delete the subst drive

subst X: /d


TIP:
There is also a great freeware utility called Visual Subst to make things even easier:












How do you mount a directory as a drive in Windows 7?

How do you mount a directory as a drive in Windows 7?
---------------------------------------------------------
If you have touched DOS before, you might still remember what this old school command subst

is all about. It is a command used for substituting local paths on physical and logical

drives, known as virtual drives. For example, if you want to have a logical drive N: mapped

to a local folder on your computer, say c:\temp, you can simply use the following command to

make it.

    subst N: c:\temp

If you want to have it permanent, there is a really nasty and hidden trick, creating a new

key in the registry.

You have to go to

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices

and there create a key named with the drive letter you want, colon included
(N: in our example) and with this value:

\??\c:\\windows


you can obviously change c: and windows for whatever folder you want, but remember to double the backslash after the unit letter, because it won’t work with a single backslash.
Reboot and enjoy your new N: :)

To Delete the subst drive

subst X: /d


TIP:
There is also a great freeware utility called Visual Subst to make things even easier: