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

Hi, 

I am implementing Q2A as part of my web app (using YII framework). I got most of the stuff working but the relative URLs are causing some issues. I would like to enforce absolute urls everywhere in Q2A including the form actions.

is there an esier way to achieve that? I saw  question #11847 and Gideon's suggestion to use qa_q_path for specific pages but it doesn't solve my issues. I would prefer if there is a sigle place where I can define / overide and have all the urls as absolute urls. 

is it possible or am I looking to refactor a lot of code? 

Thanks for your help.

Nikhil

Edit: Here are more details

Lets say we have two urls 

a. example.com/q2a/admin, and

b. example.com/q2a/questions

My app has its own URL management and if there are relative paths in Q2A then I am seeing two issues

1. Once in the admin page (url 1), every thing else points to admin/<URI> so url b  above will become example.com/q2a/admin/questions which ofcourse is not right

2. Once on the home page, all the pages jump one directory above so from q2a home page the new url for b becomes example.com/questions skipping the q2a directory part

 

For my test, I got most of the absolute paths working by changing  qa_q_path and qa_q_path_html default for $absolute=true and also within the app converting any call to these two functions with $absolute=false to true. this approach is messy and perhaps I should override the above two methods to always use $absolute=true so as to minimize the changes to q2a code... 

All the url's work fine now but I can NOT submit any form. e.g. for ask form, the page url is example.com/q2a/ask and the form post method shows action example.com/q2a/?qa=ask which is still ok as I can access the page with this url but nothing happens when I submit the form. Same story for all the forms. They are not working. No error message nothing. Not sure is this is due to URLs or I messed up something else. will keep probing... if someone has any pointers, a better approach will appreciate it.

Q2A version: 1.5.2
by
Out of interest, what issues are you having with the relative URLs?
by
Thanks Gideon. I decided to run Q2A on its own without integrating inside my app. Instead I wrote a couple of webservices in my main app to return the header and footer which I used in Q2A via customized theme / layer. It turned out that after fixing the URLs I was still looking at a lot of refactoring as javascript / css classes etc were messed up after integration.
by
I am having same problems with the relative URLs.I followed the methods like setting absolute =true .This works well for absolute paths but in cases like login URL " http://localhost/qaproject/index.php/login?to=" its not working.So i would like to know if you got any solun
by
Hi, As I mentioned I went the other way and did not use absolute urls in the end. For login I fixed the qa_get_login_links method in qa-external-users.php thats where you can customize the links and it is well documented. Hope it works out for you.
Nikhil

1 Answer

0 votes
by

All URL generation goes through qa_path(...) in qa-base.php - you can create a plugin which overrides this, setting $rooturl to qa_opt('site_url'), before calling back through to the base function.

...