I'm creating a website for homework and it's going to have multiple pages. I'm using bootstrap 4 and for each page, I have to declare a lot of links and scripts on the head of the HTML.
My question is if it's possible to add a single link via HTML or a PHP include so I can use a single line for all the additions and edit them all on a single file.
This is what I have
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="stylesheet.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
I want something like this
<head>
<title> </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="alltheotherlinksandscripts.php">
</head>
Or this
<html>
<head>
<title></title>
<?php
include_once "alllinks.php";
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body> </body>
</html>
You can. Put the header in a separate php file and you can include it in all files.
<head>
<?php include('header.php'); ?>
</head>
Yes, you can set all links (js/css libraries) in one file i.e alllinks.php
and call that file in your <head> part like..
<head>
<?php include('alllinks.php'); ?>
</head>
Related
I have a very basic webpage with two files, index.php and style.css
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Test</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<script language="JavaScript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
Example text
</body>
</html>
body {
text-align: center;
}
If I navigate to www.example.com this page loads correctly. WAMP automatically takes me to index.php. However if I navigate explicitly to www.example.com/index.php the css fails and everything reverts back to the default of being left-aligned.
EDIT: I originally blamed this on a GET variable but I have realised that's not the issue
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<title>**********</title>
<link href="css/main.css" rel="stylesheet" />
<link href="css/home.css" rel="stylesheet" />
</head>
<body>
<?php
// top navigation
require_once("require/top_navigation.php");
// header
require_once("require/header.php");
// main
require_once("require/main.php");
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="js/main.js"></script>
<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v5.0&appId=411386782258918&autoLogAppEvents=1"></script>
</body>
</html>
...
I haven't done much direct php for a while, but when I seem to use the require_once it adds a blank text element followed by 1. I've looked all over google and everyone that I've come across says it's because of BOM. So I checked on the editor that I use 'Visual Studio Code', and it's not enabled, by default it's UTF-8 without BOM.
The apache software is Xampp.
Here is the title and link I used with the header, but I just get the word "Document" instead
<title>Chicken and Waffle | Local 360 | Gunyen</title>
<link rel="shortcut icon" type="image/png" href="images/gunyen%20logo%20dark.png">;
sample: https://gunyen.com/post/local360chknnwfl.php
What am I doing wrong?
Check your code again! This is the page source code I see in my browser:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="docsearch:language" content="en">
<meta name="docsearch:version" content="4.3">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link rel="shortcut icon" type="image/png" href="images/gunyen%20logo%20dark.png"/>
<!--https://developers.google.com/search/reference/robots_meta_tag#directives-->
<!--<meta name="robots" content="index, follow, archive">-->
<meta name="robots" content="nofollow, noindex">
...
As you can see, there are 2 head blocks!
Most browsers will pick up favicon.ico from the root directory of the site without needing to be told; but they don't always update it with a new one right away.
However is a correct way to achieve your task with the name of favicon.ico:
<link rel='shortcut icon' type='image/x-icon' href='images/gunyen/logo/favicon.ico' />
Reference: https://stackoverflow.com/a/9943834/6366593
I am trying to create a PHP file that will contain scripts, css links and resources just like I have header.php and footer.php. However, when I create that file and include it in my <head> it does not apply to the page in question.
I have tried including it in <head> tags and <body> tags above the PHP include header.php but still no results. I tried different formats as well.
<?php include 'includes/scripts.php'; ?>
<?php include ('includes/scripts.php'); ?>
I want to inlcude files such as:
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
header location for the code
index code location
scripts file
In your header.php file, and script.php file remove the <HTML>, <HEAD>, <BODY> tags, and also remove the <meta charset="utf-8">. In both of the files, keep only what you want to include into your index.php file.
You do not need to include the script.php file in the header.php file, instead include it only in the index.php file.
So you can keep only these things in your script.php file:
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
Also in your header.php file you can keep only the contents which is wrapped with the <nav> element, and finally include the both files in your index.php file as below:
<!DOCTYPE html>
<html>
<head>
<?php require('includes/script.php');?>
</head>
<body>
<?php require('includes/header.php');?>
// your rest of your elements here
</body>
</html>
I'm trying to add the following code
<!DOCTYPE html>
<html version="HTML+RDFa 1.0">
<head>
<meta charset="utf-8" />
<meta content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<link href="https://socialhub.s3.amazonaws.com/production/styles/sr-socialhub.carousel.default.css" rel="stylesheet" />
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<!-- Note - you may not need to include jQuery if you already have it. -->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://socialhub.s3.amazonaws.com/production/scripts/app-carousel.min.js"></script>
</head>
<body>
<div ng-app="ngSocialHub" ui-view
ng-social-hub-carousel
ng-social-hub-customer="news"
ng-social-hub-board-id="out-and-about"
ng-social-hub-infinite-scroll="true"
ng-social-hub-dialog-enabled="false"
ng-social-hub-locale="en"
ng-social-hub-facebook-appid="<YOUR FACEBOOK APP ID HERE>"
ng-social-hub-interval="5000"
ng-social-hub-disable-user-actions="false"
ng-social-hub-disable-carousel-indicator="true"
></div>
</body>
</html>
into a page as inline code to my site http://dtcm.co.nz, for some reason this code doesn't seem to work with my wordpress based site, I have also tried it on another wordpress site which has no plug ins and it did not work. The company who provided the code have had success with wordpress sites, however sometimes have come into problems. will there be anything that will be restricting my wordpress from allowing this inline code to work?