Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
1.6k views
in Q2A Core by

I found this:

http://www.question2answer.org/qa/8309/how-populate-database-with-tags-without-creating-bunch-posts

But apparently it isn't compatible with the current version (and the explanation isn't very clear to me as a new user).  

Is there a way to do this with 1.5.3?

 

 

 

Q2A version: 1.5.3

2 Answers

+2 votes
by
edited by
 
Best answer

OK, I've answerd my own question by writing a patch.  Here it is:

https://github.com/martin05rc/Import-Tags

Now you can add a simple plain-text file with your tags and have them come-up when a user is asking a new question.

Being that I am new to the Question2Answer codebase I am not sure if I missed anything important.  It'd be great if someone with more familiarity with the code could take a look at what I've done and comment.  In particular, I am not sure when and where qa-page-question-post.php is used and don't know if I've fully tested it.

 

 

by
Thanks, but it's not working for me.
I overwrite the files then add the extra files in qa-external folder but no charm.
I understand that I have to rename qa-external-example to qa-external

Something missing from my configs or anything?
by
If you simply expanded the archive into your Q2A root everything should have been taken care of.  In other words, there was no need to rename any directory.  The "qa-external-example" directory can remain as is.

OK, then, in your "qa-external" directory you should have two files:

qa-import-tags.php      
tags.txt     

Do you have those?

And you should have replaced:

<site-root>/qa-include/qa-page-ask.php
<site-root>/qa-include/qa-page-question-post.php

with the new versions.

Did that happen?

If so you should see tags from tags.txt appear as you type tags into the Tags textbox of a new question.  To be clear, this mod does not add tags into the database at all.  You will not see these tags in the  "Most popular tags" list unless you actually use them in questions.  Maybe that's the issue?

BTW, I'm running 1.5.3 and know nothing about any prior version.
by
edited by
Thanks martin05rc,
Yes now I see the tags in matching suggestions.
Actually I had to rename the folder to qa-external from qa-external-example otherwise ask link gives error.
I was thinking the other way that the tags will be visible on site even when no questions exist. I am not sure if it's a good to populate tags in the entire site so it's visible everywhere in the list of Tags link.
I believe it's all about reputation and points, is it?
by
Tags in the popular tags list have questions associated with them.  I suppose one could create a new list of tags without questions.  That's another project.
by
slight problem here, when using swedish like Å Ä ä gives format problem like question mark symbols in suggestions
by
edited by
OK, edit the qa-import-tags.php file.

Change this:

$tag = fgets($file);

to this:

$tag = utf8_encode(fgets($file));

Also change this:

$new_key = strtoupper($new_key);

to this:

$new_key = mb_strtoupper($new_key, 'UTF-8');

When you select your desired tag you will see that letters with accents will display with in lower case in the Tags textbox.  Despite this, once you post the question the tags are displayed correctly.  I need to find where Q2A does it's own case conversion and possibly switch it to the md_strtoupper function as well.

Please let me know if it does and I'll update the code in GitHub accordingly.
by
I am editing files now.
About the case conversion; is it in css? I am not sure but I see that case changes in pages because of css of theme.
by
Your software works!
Tags are displayed in capitals, yes capital in tags box hints as well.
by
Thanks for the feedback. Just updated GitHub with this modification.
by
This file is no longer available at the link above.
0 votes
by
There is a much easier way to do this. Just fill in the words directly into the table qa_words and set two values to 1!

Sample-Insert-Script:

INSERT IGNORE INTO qa_words SET word='zypern', titlecount=0,contentcount=0,tagwordcount=1,tagcount=1;

The word has to be in lowercase then everything works fine. I filled about 4.800 words into the database!
by
I believe this will get undone if you run the db clean up operations found at Admin -> Stats.
...