Additional menu

How to export K2 items to Joomla Articles

How to export K2 items to Joomla Articles

Geek Flare Blog post is sponsored by Netsparker Web Application Security Scanner.

Migrate K2 items to Joomla! articles in two easy steps using phpMyAdmin

K2 is great but if you are in the mission of removing a dependency on any third-party extensions and migrate K2 items to Joomla articles then this article will help you.

1. Migrate K2 categories to Joomla

  • Access phpMyAdmin and go to SQL Query box of respective database
  • Enter following queries in query box and click on Go

phpmyadmin-querybox

insert into geek_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, ‘com_content’, from geek_k2_categories 

Note: you got to change from geek to your database tables prefix. You can find tables prefix name from Server tab under Joomla Administrator>>System>>Global Configuration

2. Migrate K2 items to Joomla

  • Enter below queries into query box and click on Go
INSERT INTO `database_geek`.`geek_content` (`id`, `title`, `alias`, `catid`, `introtext`, `fulltext`, `created`, `created_by`, `publish_up`, `publish_down`, `access`) SELECT `id`, `title`, `alias`, `catid`, `introtext`, `fulltext`, `created`, `created_by`, `publish_up`, `publish_down`, `access` FROM `database_geek`.`geek_k2_items`

Note: you got to change two things here.

database_geek – change with your database name

geek – change the table prefix as you found in step number 1

Now, you should have K2 items into Joomla! content. This has helped me when I migrated K2 to Joomla and hope it will you too.

Reader Interactions

Chandan Kumar
About Chandan
Chandan Kumar is the founder of Geek Flare. Learn more here and connect with him on Twitter.

Comments

  1. #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”data_yaz’.’kuza_content’ (‘id’,’title’,’alias’,’catid’,’introtext’,’fu’ at line 1

    please help : (

  2. Hello Everyone!

    Thanks for posting this Chandan Kumar. It helped a lot. However there are some issues. Here is what I did to fix them.

    1. There is a difference between these quotation marks ‘ and ` this site’s type settings makes it hard to differentiate. this ‘ is for fields and ` is for values.

    2. insert into yourdatabaseprefix_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, ‘com_content’ from yourdatabaseprefix_k2_categories

    This syntax is not necessary as it does not bind the articles to the categories after import. However, if you have millions of categories, may be it will be useful.

    3. If you run the second syntax which is supposed to import the values i.e articles into the joomla articles a couple of errors with come up. a. no-zero-date error will be thrown up and b. the quotation mark error will also come up. This second syntax requires you use the ` which is for the values not the normal ‘ quotation marks.

    4. before you run the second syntax you should update the yourdatabaseprefix_k2_items table columns that has zero dates in it. MySQL will not import zero values as dates. I ran the following: UPDATE yourdatabaseprefix_k2_items SET modified = created, publish_down = publish_up, checked_out_time = created;

    This changed the zero dates to something else other than zero. You can modify this as you see fit.

    5. Now run the second syntax which I have modified with more columns and the IGNORE statement to fix no default image error that comes up without it:

    INSERT IGNORE INTO `yourdatabase`.`yourdatabaseprefix_content` (`id`, `title`, `alias`, `catid`, `introtext`, `fulltext`, `created`, `created_by`, `checked_out_time`, `modified`, `publish_up`, `publish_down`, `access`) SELECT `id`, `title`, `alias`, `catid`, `introtext`, `fulltext`, `created`, `created_by`, `checked_out_time`, `modified`, `publish_up`, `publish_down`, `access` FROM `yourdatabase`.`yourdatabaseprefix_k2_items` ;

    I suggest the OP should create a text file that clears up the issues with quotation marks and whatnot.

  3. Hi! Thanks for the help, i am doing it and getting this error:

    “#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from news_k2_categories’ at line 1”

    Do you know what could it be?

  4. So, would you be so kind to tell us how to catch up K2 featured images (first header image) of articles too? It works but only with article content, excluding extrafields.

    Any ideas? Tnx

  5. HELP ME PLEASE

    I got the error #1054 – Unknown column ‘‘com_content’’ in ‘field list’
    i tried with INSERT IGNORE but keeps going on!
    Any Idea?

    INSERT IGNORE into xxxx_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, ‘com_content’ from xxxx_k2_categories;

    • for:
      I got the error #1054 – Unknown column ‘‘com_content’’ in ‘field list’
      i tried with INSERT IGNORE but keeps going on!

      copy + paste the following and change to ur db prefixes … then change the quotation marks from ‘ to ‘

      so instead of ‘com_content’ it will be ‘com_content’
      ——————
      insert into geek_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, ‘com_content’ from geek_k2_categories

      • this website changes them back to the wierd quotation marks…just delete the single quotation mark around com_content and write them back again…should work

  6. Everything worked with no SQL errors, but when I go to my categories I get the following warning:
    Warning: str_repeat(): Second argument has to be greater than or equal to 0 in \administrator\components\com_categories\views\categories\tmpl\default.php on line 193

    • Had the same problem but figured it out. It is because the parent level is messed up. The copied categories are having a level of ‘0’. You will have to change them to 1 or more

  7. So…the summary
    For the first code – remove the comma before ‘from’
    For the second code – just insert IGNORE after INSERT, as wph4 already told here above.

    Good luck to everyone!

  8. If you have this error in MariaDB : #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from xxxxx_k2_categories’ at line 1

    You need to do something like that :

    INSERT INTO dzzz_categories (title,alias,parent_id,published,access,extension) SELECT name,alias,parent,published,access,’com_content’ FROM dzzz_k2_categories

  9. insert into mainj_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, mainj_content, From mainj_k2_categories

    MySQL said: Documentation
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘From mainj_k2_categories’ at line 1

  10. Hi Graham, the same issue like others.
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from hrk32qe_k2_categories’ at line 1

    Please, update this post and help us!
    Thanks!

  11. I cant make tis to work, I have this message:
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from prefix_k2_categories’ at line 1

    I tried the xtra comma, etc

  12. I get this error
    #1054 – Unknown column ‘‘com_content’’ in ‘field list’

    Can anyone help me please?

  13. Hi, Thans for the codes.

    For the first one I had to change the (‘) signs.

    For the second one I am getting this code.
    What should I do?

    #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’

    Thanks!!!

  14. I get this error
    #1054 – Unknown column ‘‘com_content’’ in ‘field list’

  15. i have same error
    mysql 5.5.35 php 5.3 phpmyadmin 4.4.6

    query:

    insert into zap0v_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, ‘com_content’, from zap0v_k2_categories

    error: near ‘from zap0v_k2_categories’ at line 1

  16. i get this error:
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from xxxxx_k2_categories’ at line 1

Leave a Reply

Your email address will not be published. Required fields are marked *

Share
Tweet
Stumble
Share