Link to home
Get AccessLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

How do I incorporate a # dynamic in a Laravel route?

I've got a page with a list of testimonials and at one point on the site, I have this:

<a href="testimonials#{{$test->id}}">read more...</a>

The idea being that when the user clicks on the link, they're taken to the and advanced to the testimonial with the id of 2.

I've got that particular testimonial listed with a <a name="2"></a> like you would expect but it doesn't seem to work.

Any ideas?
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
Avatar of Bruce Gust


Everything is on my local box right now, but the link looks like this:

Now, something's happening because the page does advance to a position other than the top of the content, but it's the same position every time which is what lead me to believe that something was "off."

If you're telling me that everything looks good from you standpoint, I'll go back and pop the hood on this and see if I'm not missing something obvious. My biggest concern was that there might be something within the Laravel paradigm that required a special accommodation for a route followed by a "#" character.
OK Bruce,

No ... nothing special in Laravel and your code looks good.

Like I said, view the source of the page that contains the links to make sure they're all working properly, and then view the source of your testimonials page so make sure the <a> tags have their name set correctly.

FYI - you don't have to use an empty <a> tag for this - it'll work just as well with an ID on an element, such as a DIV.

<div id="1">

<div id="2">

Open in new window

I figured it out, Chris!

The # dynamic was working. The problem was that the content of the page would go all the way to the top of the page behind the header portion so you couldn't see / tell what was going on.

Bottom line: I got it done!