I tried to add icon with code
<link rel="shortcut icon" href="<?php include($_SERVER['DOCUMENT_ROOT'].'/imageslogos /favicon.ico'); ?>" />
When I look at the source code it showed lots of ? a few letters and numbers
When I clicked on this it said
The requested URL's length exceeds the capacity
limit for this server.
How do I add the icon from document root
You shouldn't use the include function since the link tag needs a reference.
Try this
<link rel="shortcut icon" href="
<?php echo $_SERVER["DOCUMENT_ROOT"]."/imageslogos/favicon.ico"; ?>
"/>
Related
I am having trouble fully implementing solution to question How do I force a favicon refresh?.
Current header.php is not refreshing the favicon as intended:
<link rel="shortcut icon" type="image/x-icon" href="...favicon.ico?v=2" />
<?php favicons(); ?>
I do not understand the role of the second line. I have found that adding a character to the end of the second line forces the favicon refresh (good!) but also displays a new line of text—whatever * is in below example—at the very top of the website (not good):
<link rel="shortcut icon" type="image/x-icon" href="...favicon.ico?v=2" />
<?php favicons(); ?>*
What is the role of the second line? How should it be formatted to force the favicon refresh without displaying a new line of text at the top of the website?
Thank you for your consideration, please let me know what other context I can provide.
i need some help with linking css to a php file.
This was completed by someone else and now i need to fix it. We have the main css that controls the look and feel of the entire site. The other CSS is just for the accordions page. that needs to be added in.
Current links include:
<!-- CSS Linking -->
<link href="css/template.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/accord.css" rel="stylesheet" type="text/css" />
If i remove the ?php echo from the second one it doesn't work, but if i leave it in there the css/template.css doesn't work.
Basically if both are in there are the same time they one doesn't work. Is there are way to resolve this?
The answer was that in the css of the second file there was an element of code that was overwriting the other file. The people had a body element. This has been removed and now both working together well.
In the beginning of the PHP file, I am defining the ROOT as
define('ROOT', dirname(__FILE__));
It works when i use something like
require_once(ROOT . DIRECTORY_SEPARATOR . 'config/bootstrap.php');
However, when using the same ROOT while including the css within the HTML seems to create a problem.
<html>
<head>
<title>PrePress · Login</title>
<link type="text/css" href=<?php echo ROOT . DS . 'views/type.css ?> rel="stylesheet">
</head>
<body>
Test
</body>
</html>
On tracing the path of the CSS file, the full path starts with http://localhost:8888/Users/.... Here I simply want my path to start from /Users/ which will be able to find my css file, whereas having the localhost changes the path and the file can no longer be found.
<link type="text/css" href="<?php echo $_SERVER["DOCUMENT_ROOT"]."/views/type.css"; ?>" rel="stylesheet" />
You do not need to use that format in an href. Just use
<link type="text/css" href="views/type.css" rel="stylesheet">
To give a relative address, which makes the code much more transportable
use
<?php $path = glob($_SERVER["DOCUMENT_ROOT"]."/views/type.css"); ?>
<link type="text/css" href="<?php $path; ?>" rel="stylesheet" />
You have to set the base url and that should link to your project folder. If you are not using a framework then I suggest you do.
Once you have set your base url you can call css and javascript from your header and footer respectively, and include the header and footer on your pages i.e $this->load->view('includes/header); and $this->load->view('includes/footer);
This is how you would typically call your scripts, I have only mentioned the href property within the tags as you should know the rest.
<script href="<?php echo base_url('link to your script goes here');?>" />
<link href="<?php echo base_url('link to your sheet goes here);?> />
I have following code for my header.php file, in the includes folder.
<html>
<head>
<title>Health Mate</title>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link href="stylesheets/public.css" media="all" rel="stylesheet"/>
</head>
<!-- Some more code-->
</html>
I have pasted favicon.ico in the includes folder itself.Problem is the favicon is not setting up.Also If i redirect user to some site on submit button like yahoo.com . My site is taking favicon of yahoo. Please suggest some solution. Also tell me if favicon needs to be .ico file or it can be .png as well?
You should have necessary path needed to locate your favicon.ico image.
Eg: If your folder is structured this way:
/mysite
/includes
favicon.ico
index.php
If you're going to use it in index.php you should include the necessary path needed like this:
<link rel="icon" href="includes/favicon.ico" type="image/x-icon" />
Note: for checking if your like get the path towards your icon image..
you could check your web page source code using ctrl + u. Then click the href path linked if it displays the image it means your path is correct.
You have to put favicon.ico in to root directory of your website such that anyone can access it by yourdomain.com/favicon.ico. yourdomain.com/includes/favicon.ico will not work without a link tag.
If you can't put the favicon on the root folder for your domain then you have to use this code and change the href attribute to match the path to the favicon relative to the root of your site. i.e. /includes/favicon.ico
<link rel="Shortcut Icon" type="image/ico" href="/includes/favicon.ico">
I would recommend converting the file to an actual .ico using http://www.icoconverter.com/ or some equivalent tool.
I am using nice urls without rewrites (e.g. /my/site/index.php/some/page). I am having trouble with stylesheet links. For example, sheet.css is getting interpreted as /my/site/index.php/some/sheet.css.
How can I get it to link correctly, for any prefix (/my/site/) and any depth suffix (/some/page)?
add a / in front of any resource to point them to the root directory of your site:
<link rel="stylesheet" type="text/css" href="/sheet.css">
You can always setup a CONSTANT in your included config file and add the site path to it
define('HOST_URL', 'http://www.example.org/my/site/');
define('HOST_URL', 'http://www.example.net/my/site2/');
then you can call any file and change the paths whenever you want from 1 single file.
Eg:
<link rel="stylesheet" type="text/css" href="<?php echo HOST_URL; ?>sheet.css" />
<script type="text/javascript" src="<?php echo HOST_URL; ?>script.js"></script>
<img src="" alt="<?php echo HOST_URL; ?>images/image.jpg" border="0" />