Good day All
I'm am working on my first laravel project and I ran into a problem that I cant seem to fix.
I have a few basic views, controllers, and routes that work together with a basic HTML navbar. The problem I am having is that when I click on the next page in my navbar it works fine and it goes to the link but when clicking on another link from that page it adds to the path and then it can't find the page. My routes work through the basic controllers that return a view only for now
For example
Example:
Home page=http://127.0.0.1:8000/
Click on Movies=http://127.0.0.1:8000/movie/index
Click on Movie Actor=http://127.0.0.1:8000/movie/actor/index
from movies to the next view it does not work as you can see the link path is wrong it should be http://127.0.0.1:8000/actor/index
please if anyone has any suggestion that might help.
Please edit your questions with the code and include the relevant code for the future. The code you posted doesn't contain any links (Edit: in your first few comments), which gives me a reason to believe you pasted the wrong thing.
The problem (without seeing any of your code) is likely here.
<a href="movie/index".....</a>
The way this (a) element works, which has nothing to do with Laravel, but is purely HTML, is that it will add movie/index to the current path you are linking from because you are giving it a "relative" URL.
If you add this link from, e.g. yoursite.com - it will link to yoursite.com/movie/index if you do it from yoursite.com/dashboard, it will link to yoursite.com/dashboard/movie/index.
Instead, you do not want a relative path, so you need to start with a / like this.
<a href="/movie/index".....</a>
You can read more about HTML tags here: https://www.w3schools.com/tags/att_a_href.asp.
Check named routes in documentation.
Route::get('/user/profile', function () {
//
})->name('profile');
You can get absolute url in blade template with route helper.
Text
Related
I have this 2-page website which uses angularjs. I like to be able to load page 1 on a certain position by clicking a link on page 2.
Normally, without angular you would give a div an ID like <div id="test"> and put a link on page2 test
On my angular website I use duScroll library to create smooth scrolling.
As a concept I've created the following example website: http://jdenuijl.com/test/#chapter2
this link will open the correct location and smoothscrolls when clicking the links at the top of the page.
On my production website the following link https://escapist.nl/nl/#gallery gets rewritten to https://escapist.nl/nl/#!#gallery and it doesn't open on the correct position.
I've read a lot of questions on stackoverflow about $hashprefix, $locationProvider, $location but I don't see why it's working on my test site and not on my production site. I use some other angularjs functionalities on the production website but I can't find what is causing the rewrite.
What is causing the rewrite and the failure of the normal behaviour?
Thank you very much!
Aleksey Solovey put me in the right direction. I was using the angular-google-analytics module which I found out was loading ngRoute which caused the problem.
6:23 AM (1 hour ago)
Hi, can anybody help to understand how to create Internal links (Anchor Links) in a post? I can't able to find any helpful answer. Feeling very frustrated.
I did exactly what a person said me on the Blogger product forum -
For anchor link:
You can create hyperlink in the HTML mode. Just insert the following code where you want to place an anchor. (you can change archorlinkname to whatever you like)
<a name="anchorlinkname"></a>
For the link within the same post that you want to jump to that anchor, please use this code. (you can also change the word in yellow)
Click here to go to anchorlinkname
But something weird is happening once I am updating my post or going from HTML mode to Compose mode.
Error -
<a href="https://www.blogger.com/blogger.g?blogID=48019486#overview">
I don't know why these https://blogger.com/blogger.g?blogID=48 and https://blogger.com/null gets added automatically. It redirecting me back to the admin post section or to blogger sign in section if I am not Signed In.
My Blog - www.lifewithdata.com
Found the answer here: https://productforums.google.com/forum/#!topic/blogger/5MU_HH5T7rA
you must add the address of the page or post.
only works in the non-dynamic templates.
Peace be upon those who follow guidance, I was able to make internal links within post on blogspot platform by using anchors like below:
sectionName
<a name="sectionName">sectionName</a>
I was using a theme based on Dynamic Views and worked for me, and changed it to other theme and the links still work.
I'm wondering if someone could advise me... I am not very familiar with AngularJS but I am currently working on a site that uses it. I have several scenarios where I have to link to an anchor link on a different page/different url and if I was to simply put it as this for example:
Click here to view this link
It causes a 404. I have found several solutions for anchor links within the same page but nothing that works with AngularJS to link to an anchor link on a different page/url.
Can anyone help? Thank you.
Angularjs parses href's for redirection. It attempts to go to a view with anchorlink
Try setting this in your routes
// use the HTML5 History API
$locationProvider.html5Mode(true);
And om your html header, set a base location of your site with <base href="/">
This should make angularjs stop interfering with anchor tags in your urls.
EDIT
#Sabarish Senthilnathan's comment works also, probably the best way too.
My site uses both PHP and the JS AJAX so I'm fairly familiar with them both, and I don't want a solution that includes them. I have this page structure where all my users stay on just one landing php page, which then fetches the right content depending on the URL's p variable.
http://www.example.com/?p=about
http://www.example.com/?p=aMap-anothermap-evenAnothermap-lastelyTheFile
This page structure works great for me except that I don't know the right way to make a link that just removes the whole ?p=home. Because I want my home/start page to be variable free. I want it to be
http://www.example.com/
rather than
http://www.example.com/?p=home
Now I could just make the link
http://www.example.com/?
And then just remove the ? with the JS pushState(), but that would look pretty silly and would only work for JS users.
Let's say i would want to the do the above example with just the ? then I could create a link like this.
Link
<script src="SomeCoolPushStateScript"></script>
And I know from experience that this doesn't even work:
Link
So here comes the question: How do I remove the ?variable=something part of an URL when using an HTML href?
The path ./ should do the trick.
Link
If you want to preserve the main script name, like index.php, you will have to include that name.
Link
Alternately, you could dynamically generate domain-relative or absolute URL's with PHP.
You don't need to use querystrings.
Link
would go to example.com's root.
I don't recommend using "./". This would do what you want if the user is on a page that is in the root directory of your website (e.g. http://www.example.com/page.html). However, this would not work if they were on a page in a subdirectory. E.g. if the user's on http://www.example.com/hello/page.html, it would just link to http://www.example.com/hello/.
Using "/" makes sure the user goes to the root of your website.
I'm trying to parse a page to find all valid urls, but here is a problem. There are 3 types of links on a page: url (_http://site.com/dir/page.html), absolute uri (/dir/page.html) and relative uri (dir/page.html without starting slash). Probably i'm wrong about terminology, i'm not an html coder. But that's not the case in any way.
I need to find and collect all urls (i.e. _http://site.com/dir/subdir/page.html and so on). And here is the problem. If there is a page _http://site.com/dir/page.html with a link like link it's supposed to bring us to _http://site.com/dir/subdir/page.html. But if there is <base href="/"> in the head section of a page, same link leads to _http://site.com/subdir/page.html i.e. different from _http://site.com/dir/subdir/page.html.
The question is if there can be anything else in html code on a page that can influence target url.
Thanks in advance.
In HTML as such there is nothing else beside the href base You mentioned
What could become tricky and should be considered is that there might be linkage on page made by script execution, so things like window.location.href = something. This would be easy if the links are clearly stated, but they might be also computed by the script and then You could miss the link or mis-read it by using simple parsing.
Your problem is actually how url linking in html works, please read: http://www.webdevelopersnotes.com/design/relative_and_absolute_urls.php3 . So say you're in /admin/ and you need /admin/login.aspx . My relative URL is login.aspx, while my absolute is /admin/login.aspx make sense?
So basically what I'm saying is consider which directory your link is being served out of. That will determine the type and content of the url link to use.
Other than that, as stated already, jscript and server side code can also do linking.