.vue file router link to external url? - php

I'm making changes to a navigation menu in a .vue file in my laravel application. I'm trying to link to an external url such as https://google.com but if I change the code to an link, the link doesn't show when I compile.
I've tried changing to router-link to an external website, but it didn't work. It tries to go to that as a page /https://google.com
<li class="nav-item" #click="closePanel">
<router-link class="nav-link" to="/campaigns">
<i class="fal fa-layer-group"></i>
<span>Campaigns</span>
</router-link>
</li>
<li class="nav-item" #click="closePanel">
<router-link class="nav-link" to="https://google.com">
<i class="fal fa-layer-group"></i>
<span>External website</span>
</router-link>
</li>

It seems like the only way is using
<li class="nav-item" #click="closePanel">
<a href="https://google.com" target="_blank" class="nav-link">
<i class="fal fa-layer-group"></i>
<span>External website</span>
</a>
</li>

One way would be using window.location.href . For e.g
<a href='redirectTo("https://google.com")'>Redirect to google</a>
And on methods defination of redirectTo
methods:{
redirectTo(url){
window.location.href=url;
}
}

You need to understand two things-
router-link doesn't consider external URLs.
router-link can wrap one element.
To fix this, you fill prop to with any value and use an anchor tag inside this, like below-
<li class="nav-item" #click="closePanel">
<router-link class="nav-link" to="https://google.com">
<a href="https://google.com">
<i class="fal fa-layer-group"></i>
<span>External website</span>
</a>
</router-link>
</li>

Related

How Could I make This Redirect To Another (External) Website

How Could I make This Redirect To Another (External) Website, unsure
<li class="nav-item">
<a class="nav-link" href="#news">Link Accounts</a>
</li>
<a class="nav-link" href="EXTERNAL_WEBSITE_LINK_HERE">Link Accounts</a>
Eg:
<a class="nav-link" href="https://www.google.com">Link Accounts</a>

Redirecting to another page in laravel

I have a basic navbar in my web page. When I click any nav-items I am trying to redirect the user to another page.
I have route set up for that but when I click that nav-item I am not able to redirect it.
HTML
<div class="collapse animated fadeInLeft" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active"> <a class="nav-link" href="">Home</a> </li>
<li class="nav-item"> <a class="nav-link" href="#">Features</a> </li>
<li class="nav-item"> <a class="nav-link" href="#">Pricing</a> </li>
<li class="nav-item"> <a class="nav-link" href="{{ Route('staticController#contact') }}">link</a> </ul>
</div>
Routes.php
Route::get('/','homeScreenController#index');
Route::get('/contact','staticController#contact');
If I try to do this,I get a error message that on my homepage itself saying,
Route [staticController#contact] not defined.
but I have already defined it.
and when I do this error doesn't come but it will not take me to contact page.
<li class="nav-item"> <a class="nav-link" href="{{ ('staticController#contact') }}">link</a> </ul>
Try like this:
<a class="nav-link" href="{{ url('/contact') }}">link</a>

My wordpress links display to the wrong site

My wordpress sites redirects to the wrong location. Go to www.theladieschampion.com
On the left side bar you have the option to click on social media links. When you click on the social media link instead of going to www.facebook.com/theladieschampion it goes to:
www.theladieschampion.com/www.facebook.com/theladieschampion
Why is the happening? Even when I create buttons that lead to links on mysite the links URL gets placed over the sites URL. Please Help
You must be using your anchor tag as
Facebook
Change this to
Facebook
your code should look like below:--
<div class="social-links">
<ul>
<li>
<a class="social fb" target="_blank" href="https://www.facebook.com/TheLadiesChampion/">
<i class="fa fa-facebook"></i>
</a>
</li>
<li>
<a class="social tw" target="_blank" href="https://twitter.com/theladieschamp_">
<i class="fa fa-twitter"></i>
</a>
</li>
<li>
<a class="social gg" target="_blank" href="https://plus.google.com/+TheLadiesChampionOfficial/posts">
<i class="fa fa-google"></i>
</a>
</li>
</ul>
</div>``

How can I set class="active" to navigation menu in codeigniter?

I just start up to be a web developer. Now I create a dynamic website for the first time. I don't know how to set class="active" to the navigation menu.
Here is my menu code:
<li>
<i class="fa fa-users fa-lg"></i> Create Patient
</li>
<?php } ?>
<li>
<i class="glyphicon glyphicon-list-alt fa-lg"> </i> List Patients
</li>
<?php if( $usertype == "Admin"){?>
<li>
<i class="fa fa-list fa-lg"> </i> List Users
</li>`
You can use $this->uri->segment();
<li>
</i> Create Patient
</li>
<?php } ?>
<li>
</i> List Patients
</li>
<?php if( $usertype == "Admin"){?>
<li>
</i> List Users
</li>
I do this on most projects. How I achieve this is like this;
<i class="glyphicon glyphicon-list-alt fa-lg"></i> List Patients
It's matching the current uri string, with the links href. If it matches, it add's an active class to the link.
Hope this helps.
I have also used site_url over base_url
Try this one. I think no need of javascript or jquery.
If you are using codeigniter then you can use URI Class.
Get the menu from url using
$this->uri->segment();
and apply to you code like below
<li>
<i class="glyphicon glyphicon-list-alt fa-lg <?php if($this->uri->segment(1)=="memu_name"){echo "active";}?>"> </i> List Patients
</li>
I have used Codeigniter URI Class $this->uri->segment();
Please look at my code:
<li class="<?=($this->uri->segment(1)==='technology')?'active':''?>">Tech</li>
Please note....
class="<?=($this->uri->segment(1)==='technology')?'active':''?>"
Also you can use URI Class $this->uri->uri_string()
Here is my active class for home page(index)
<li class="<?=($this->uri->uri_string()=== '')?'active':''?>">Home</li>
Contact Us

html navigational menu in wordpress

I am using html nav bar in wordpress
my html nav bar code
<li class="active">
<a href="http://www.siteurl.com/shop/" class="active">
<i class="icon-nav icon-home"></i>
Home
</a>
</li>
<li>
<a href="http://www.siteurl.com/shop/?page_id=172">
<i class="icon-nav icon-star"></i>
About </a>
</li>
<li>
<a href="http://www.siteurl.com/shop/?page_id=176">
<i class="icon-nav icon-th-large"></i>
Gallery</a>
</li>
<li>
<a href="http://www.siteurl.com/shop/?page_id=174">
<i class="icon-nav icon-comments"></i>
Services</a>
</li>
<li>
<a href="http://www.siteurl.com/shop/?page_id=4">
<i class="icon-nav icon-shopping-cart"></i>
Shop</a>
</li>
<li>
<a href="http://www.siteurl.com/shop/?page_id=187">
<i class="icon-nav icon-pencil"></i>
Blog</a></li>
<li>
<a href="http://www.siteurl.com/shop/?page_id=145">
<i class="icon-nav icon-plus-sign"></i>
Events</a></li>
<li>
<a href="http://www.siteurl.com/shop/?page_id=178">
<i class="icon-nav icon-map-marker"></i>
Contact</a>
</li>
</ul>
</nav>
I have tried to create a conditional tags for each page like below
example for home
<?php if ( is_home() ) { ?>
<li class="active">
<a href="http://www.siteurl.com/shop/" class="active">
<i class="icon-nav icon-home"></i>
Home
</a>
</li>
<?php } else { ?>
<li>
<a href="http://www.siteurl.com/shop/" >
<i class="icon-nav icon-home"></i>
Home
</a>
</li>
But this is not working
how to active the menu icons when we view the respective pages
If i use direct html navigational menu
Only way to do this is by using the wordpress navigation system
http://codex.wordpress.org/Function_Reference/wp_nav_menu
A lot of work has gone into their system, so there's no reason why you would want to replicate it.
Appart from reading the Codex (essential), you can search for tutorials, articles and Q&A's, there are plenty of them.
WordPress Wp_Nav_Menu with Icons and Active Item Highlight
We will be doing:
Home link in our wp_nav_menu that always gets current blog url
Customize each menu item as you want
Put pretty icons in our menu
Active item highlight
Function Examination: wp_nav_menu
In this tutorial, we’ll dive deep into everything that the
wp_nav_menu function can do, use the Walker Class to add a sub
description, and touch on some of its related functions.

Categories