Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.5k views
in Q2A Core by
reopened by
on clicking a question, it should redirect to an external link instead of landing to the correspondant question page....

how can i acheive it??

normally,

on clicking,

question directs to question page.

i want to achieve like this,

question directing to external link(say www.example.com)
by
+1
Can you clarify this question? I don't get it.
by
on clicking a question,

question directs to question page.

i want to achieve like this,

question directing to external link(say www.example.com)

i want to direct the user to an external link, when he clicks any questions displayed instead of directing to the correspondant question page......


Please help me with this guys
by
Does the receiving URL have a pattern in which the only varying thing is the originating question ID? E.G: http://q2asite.com/123 will be mapped to http://othersite.com/bleh/123

1 Answer

+2 votes
by
selected by
 
Best answer

I don't really see the point of having a question and when clicking it, instead of going to the question going somewhere else.

Anyway, assuming the resulting URL varies per question, you might need to create a way to map each question ID to a resulting URL (unless the URL is OK with receiving the question ID). Then you could use a layer to modify the URL dynamically.

Edit:

Based on your comment, in order to achieve your expectations you can follow these steps (assuming you're using the SnowFlat theme):

1. Locate this line: https://github.com/q2a/question2answer/blob/3320b653f94ffa1f004d51cc82f0e95f573ff411/qa-theme/SnowFlat/qa-theme.php#L365

2. Add in there this text:

$q_item['url'] = 'https://www.google.com/search?q=' . $q_item['title'];
by
Thank you very much for your reply puppy....

The resulting url say http://othersite.com/ does not varies per question....

The resulting url is same for every questions...


The only varying thing is the originating question ID? E.G: http://q2asite.com/question1 will be mapped to http://othersite.com/bleh/question1


yeah this is what i want to achieve...


once again thank you very much
by
Actually, what i am trying to achieve is to perform a google search when a question is clicked...
and the question will become the search query in this scenario....

eg:"how to modify nav-link"

when the above question is clicked,

it should perform a google search like this

www.google.com/search/q?="how to modify nav-link"
by
+1
Why are you using Q2A then? You’re not really using it at all. Why don’t you just make a page with a bunch of links to Google?
by
I found q2a as a useful software to achieve the above functionality....
by
@scott please  help me with this....

where i need to modify the navigation link of the question...... and direct it to an external site
by
@pupi

Thanks for your kind reply,

But its not working.....

its saying undefined variable on line 365...

i placed the code in line 365
by
+1
It works. If you have really added it to line 365 then you have not added it to the right file :)
by
+1
my friend,it works fine


thank you very much.......
by
my friend,i want to apply the same changes to  tags,

where i need to change???
by
pupi can you tell me ,how to make the link open in new tab or window
by
+1
...