XF 2.1 buildLink help to create own link

gaga

Member
Hi i use this to create link:
\XF::app()->router('public')->buildLink('canonical:review', $review->id, ['id' =>$review->id]),

and my url look like this:
Code:
http://xenforo.com/review/?id=12
But i want to look like this:
Code:
http://xenforo.com/review/12
Or like this:
Code:
http://xenforo.com/review?12
 
You will need to edit your route and go to the Route format text box and input the following:
Code:
:int<review_id>/:page

Make sure you update it to reflect the column you use for the review id column.

In your template, make sure your using
HTML:
{{ link('review', $review) }}

Lastly, change
Code:
\XF::app()->router('public')->buildLink('canonical:review', $review->id, ['id' =>$review->id]),
to this
Code:
\XF::app()->router('public')->buildLink('canonical:review', $review),
if your going to have it in your php file.
 
Try this:

Code:
\XF::app()->router('public')->buildLink('canonical:review) . $review->id,
And you will get:

Code:
http://xenforo.com/review/12
 
How to use buildLink to build a link for 'resources/update', if only the update 'resource_update_id' is known.

Maybe I need to get the container of if it, but do not know how. Or maybe an entity EM?
 
Top Bottom