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!