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

In a Q2A website, admin could change url structure from admin->general page. I want tu make a link with qa_path function (or other way) that work with all url structure options.

How can I do that?

I am already using such a code
    `$url = qa_path_html($request, array("postid"=>$postid));`

But with first option of url structures, this code generates wrong url:
    `[root]/$request/?qa_1=$postid`

it must be
    `[root]/$request/$postid`

Edit: Last form of url is not supported

Q2A version: 1.6.3

1 Answer

+1 vote
by
selected by
 
Best answer

If you want to get question URL than use qa_q_path() or qa_q_path_html()

qa_q_path($questionid, $title, $absolute, $showtype, $showid)

If something else than please mention what you are trying to achieve so we can try to help in that way.


Edited Answer

For qa_path or qa_path_html you need to set $request parameter with the page you want to load. For example if you want to load Questions page with Sort by Answers than you would use this

<?php qa_path('questions', array('sort' => 'answers')); ?>

So here questions is your page and sort by answers is a parameter and url will be as below

http://localhost/qa/index.php?qa=questions&sort=answers

I hope this would be helpful to you. :)

by
Thank you Jatin. I am using this function in a plugin. I have a page that accept a parameter. I wish to link to the page with parameter.
More clarity: edit-history plugin, file qa-edh-layer.php line 37 (I want to change that)
by
See my edited answer....
by
I use same code, but with first option in url structure, I don't get desired result (questions/sort/answers or questions/answers).
...