Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.4k views
in Q2A Core by
Beeing on a question page, how can one get the category url having the categoryid ?

Is there a simple way ?
Q2A version: 1.6

1 Answer

+3 votes
by

Retrieve the backpath from the qa_categories table in the database.

Then the URL is:

qa_path(implode('/', array_reverse(explode('/', $backpath))))

by
Ok, thank You so much, that is very helpful. For "retrieve the backpath..." i am using the following select. There is nothing much easier i think ?

$mycategorybackpath = qa_db_read_one_value(qa_db_query_sub("SELECT backpath FROM ^categories WHERE categoryid =  '$mycatid' "),true);
by
Looks fine but you should escape the category id better by using a # inside the main query then adding the category id as a second parameter to qa_db_query_sub(...)
by
Are there examples used in q2a somewhere ?
by
There are a lot of examples in core. Grep source code. In particular, comment of qa_db_apply_sub() in qa-include/qa-db.php is important to Rapid Application Development.
...