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

UPDATE: Q2A now supports this natively, see this question.


It's clear from a few months of using Q2A that I could do with a way to section meta-discussion - i.e. questions about the site itself (for me this would include my main site and the Q2A section).

Does anyone have any ideas for how to organise this?

Interestingly, my "ideal solution" that I came up with several weeks ago is pretty much what Stack Exchange is now doing with their new sites: Meta is a subsection of the main site, where the users are automatically inherited from the parents. And no-one gets any points from meta.

Would this be possible with Q2A by doing the following?
- Setting up a separate Q2A instance.
- Use Q2A's "single sign on" to let users log in with their account from the main site.
- Hide all mention of points on the meta site.


Another possibility would be to have a special tag like "meta" that users should add when asking about the site. Questions with that tag would be hidden from the main page but accessed from a special page.

Any other solutions?

1 Answer

+3 votes
by
 
Best answer
I think your suggested solution is a good one. It should be fairly easy to set up one Q2A instance to use single sign-on based on another.

As an experiment, you might even want to try using a MySQL VIEW or MERGE table to share the users and userprofile tables between the two installations. In other words, if your main Q2A site uses the table prefix qa_ and the meta uses qa_meta_, you would set MySQL up to treat any query on qa_meta_users as a query on qa_users, and likewise for qa_userprofile and qa_meta_userprofile.

To be honest, this may or may not work, but if it does, it's easier than writing the single sign-on code!
by
That could work I guess. Would points from the meta site be added onto the main site users though?
by
The points (and general counts of user activity) are kept in a separate table called qa_userpoints, so they wouldn't be mixed together.
by
Hi gid, I tried a "View" for qa_users and qa_userprofile. Logging in works. I reindexed user points so that the Users page displays all the real users (it didn't at first).

Posting works as admin, but not when I logged in as a test user. I got this error:

Question2Answer query failed:

INSERT INTO qameta_posts (categoryid, type, parentid, userid, cookieid, createip, title, content, tags, notify, created) VALUES (NULL, _utf8 'Q', NULL, _utf8 '2', NULL, INET_ATON(_utf8 '127.0.0.1'), _utf8 'Is this the real life?', _utf8 'Or is it just fantasy?', _utf8 'pokemaster', NULL, NOW())

Error 1452: Cannot add or update a child row: a foreign key constraint fails (`pokemondb`.`qameta_posts`, CONSTRAINT `qameta_posts_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `qameta_users1` (`userid`) ON DELETE SET NULL)

Do you have any ideas?
by
Since I'm not sure how foreign key constraints would work with a VIEW table, I suggest just removing any such constraints that are causing you problems. They're only there for consistency checking anyway.

http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
by
Thanks, removing all use userid constraints worked. (Actually, they were all pointing at "qameta_users1" which is what I renamed the old table to.) But everything seems to be working now :)
by
Sorry for noobines, but what is 'MySQL VIEW', mysql section or what ?
by
@FriendlyOne: It is a special type of table that is essentially taken from any MySQL select query. You could create a view that is a join on multiple tables. But in the case above it's just a replica of the qa_users table, but named qameta_users. (You can create views in phpMyAdmin easily, or Google for the query syntax.)

Anyway so now the meta site selects data from qameta_users, and behind the scenes MySQL returns data from the qa_users table instead.
...