I have a filepath problem after the creation of a .htaccess protected admin directory.
Here is the structure of the folder:
file-controller4.php was initially at the root of the directory next to file-controller3.php and file-view4.php was in the view directory.
To call the header.php from file-controller4.php I use set_include_path.
The problem is that the header doesn't call the css file anymore which seems to be relative to the admin directory.
Here are the different files:
Admin folder:
file-controller4.php
<?php
set_include_path ( 'E:/xampp/htdocs/url/' );
include '/view/header.php';
include '/admin/file-view4.php';
file-view4.php
<h1>This is a title</h1>
Root folder:
file-controller3.php
<?php
include '/view/header.php';
include '/view/file-view3.php';
view folder:
file-view3.php
<h1>This is a title</h1>
header.php
<!DOCTYPE html>
<html lang="en">
<head>
<!--<meta charset="utf-8"></meta>-->
<meta http-equiv="Content-Type" content="text/html;" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>A TEST</title>
<link rel="stylesheet" type="text/css" href="css/css-example.css" ></link>
</head>
css folder:
css-example.css
html, body {
margin: 0;
padding: 0;
}
body {
background-color: white;
font-family: Verdana, sans-serif;
font-size: 100%;
}
h1 {
font-size: 200%;
color: navy;
text-align: center;
}
How could I load the CSS from file-controller4 like it does correctly with the file-controller3 ?
Thanks for your help.
You can check in header.php REQUEST_URI and detect where is script - in main folder or in admin. And then build url for CSS.
Like
<?php
if (strpos($_SERVER["REQUEST_URI"], "admin") !== false) {
$css_prefix = "../";
} else {
$css_prefix = "";
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo($css_prefix); ?>css/css-example.css" ></link>
But best and correct way is change logic of your application and move file-controller3.php inside folder admin
Related
Hey i'm using laravel 9 here and im using the SB ADMIN template from bootstrap , i'm making the template as a component <x-dashboard >...</x-dashboard> and i'm passing children inside it ! but i want the children to have it's own css ( not the bootstrap one ) which is in my app.css file i added the head just so i can link the css file to the blade file but still doesn't work any solutions ?
seeProscpect.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="{{ asset('../css/app.css') }}">
</head>
<body>
<x-dashboard >
<h3 class="changeColor">TRYING CSS</h3>
</x-dashboard>
</body>
</html>
app.css
.changeColor {
color: green;
}
You have to use #pushonce for this purpose.
#pushonce('styles')
<link href="{{ mix('css/tile.css') }}" rel="stylesheet">
#endpush
Inside your <head> after all other CSS script put #stack('css')
Ex:
<head>
<link rel="stylesheet" href="{{asset('../css/app.css')}}">
#stack('css')
</head>
Then from your children blade, add #push or #pushonce
Ex:
#push('css')
<link rel="stylesheet" href="{{asset('assets/css/blade_style.css')}}" />
<style>
.body {
background: #000 !important;
}
</style>
#endpush
#section
<h1>Children Blade Content</h1>
#endsection
Php code
i searched on the web and i didnt see anything about this it looks like no error css status is 200
css code is at the bottom.
.sagalt {
margin-top: 500px
}
<html>
<head>
<meta charset="utf-8">
<title>quantum</title>
<link rel="shortcut icon" href="logo.png" type="image/png">
<link rel="stylesheet" href="qntm.css?v=<?php echo time(); ?>">
<!--link//-->
</head>
<body>
<div>
Sign Out
</div>
</body>
</html>
Think you are trying to apply CSS to the link. Anchor tag being an inline element, margin top/bottom property alone wont have an effect in it as inline elements flow with content on the page. Use display: inline-block or display: flex or float: left as per your requirement.
.sagalt {
color: red;
margin-top: 100px;
display: inline-block;
}
<html>
<head>
<meta charset="utf-8">
<title>quantum</title>
<link rel="shortcut icon" href="logo.png" type="image/png">
<link rel="stylesheet" href="qntm.css?v=<?php echo time(); ?>">
<!--link//-->
</head>
<body>
<div>
Sign Out
</div>
</body>
</html>
I can already parse a Markdown file to HTML but my problem is getting that markdown file from a URL instead of a local file.
Below is the code I have:
<?php
include('./includes/Parsedown.php');
$Parsedown = new Parsedown();
$text = 'https://raw.githubusercontent.com/dylanwe/How-to-make-a-discord-bot/master/README.md';
$slug = 'How-to-make-a-discord-bot';
$text = str_replace('img', "https://raw.githubusercontent.com/dylanwe/$slug/master/img", $text);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/themes/prism-coy.min.css">
<link rel="stylesheet" href="css/prism_github.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/4.0.0/github-markdown.min.css">
<style>
.markdown-body {
max-width: 780px;
margin: 0 auto;
padding: 15px;
}
pre[class*=language-]>code {
border: none;
box-shadow: none;
}
</style>
<title>Document</title>
</head>
<body>
<div class="markdown-body">
<?php echo $Parsedown->text($text); ?>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/prism.min.js"></script>
</body>
</html>
It's not very clear what isn't working as expected, but it looks like you just need to retrieve the contents of the Markdown file, e.g. using file_get_contents():
$text = file_get_contents('https://raw.githubusercontent.com/dylanwe/How-to-make-a-discord-bot/master/README.md');
I cannot figure out how to apply styles to a page I am including as a template. I have the following directory structure:
app
│ index.php
│ styles.css
│
└───include
│ │ mainmenu.php
My INDEX file looks like this
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Learn Algorithm Tracing</title>
<link rel="stylesheet" type="text/css" href="styles.css"</link>
</head>
<body>
<?php
include 'includes/menu.php';
?>
<h1>Welcome</h1>
The CSS works fine in this page and loads OK. However I'm having trouble understanding how to get CSS styles to apply to my mainmenu.php file. At the moment it looks like this.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../styles.css"/>
</head>
<body>
<p class="menuitem">HOME</p>
<p class="menuitem">I KNOW</p>
<p class="menuitem">I WANT</p>
<p class="menuitem">I GOT</p>
</body>
</html>
I added ..\ as the styles for this are stored in the main CSS file which is in the parent directory. However, it doesn't apply the menuitem style here. I've tried every combination I can think of but how do I go about it? How do I apply the styles in the main stylesheet to my mainmenu.php page when it's been included in index.php
EDIT:
Interestingly, when I include one of the styles already used in the index page it works fine, but for some reason it doesn't like the menuitem style. Here is the CSS
body{
width: 80%;
margin-left: auto;
margin-right: auto;
}
h1 {
font-family: "Verdana", sans-serif;
}
.maintext {
font-family: "Arial", sans-serif;
}
.entryprompt{
width: 50px;
}
.menuitem{
font-family: "Arial Narrow", sans-serif;
font-size: 16pt;
width: 30px;
margin: 10px;
}
try using ../styles.css instead of \..\styles.css and close the
<link rel="stylesheet" type="text/css" href="../styles.css" />
You are using bad slash in html link tag change \ to this / so CSS import will look like this.
<link rel="stylesheet" type="text/css" href="../styles.css"/>
Update:
When you include some file then you should use path from the file you are including it to. Try this.
<link rel="stylesheet" type="text/css" href="styles.css"/>
Pdf fuction*
This function is call from ajax after getting data from this function it's call anothe file here I am display data which is coming from data base.That file all css part in style tag using then as it is style tag prind in pdf as a text and if this all css file include in css folder then pdf is not create in proper format
public function actionInvoicespacking(){
$pdf = Yii::$app->pdf;
$modelShipment = Shipment::find()->orderBy('ship_id DESC')->one();
if(count($modelShipment) == 0) {
$shipid= 1;
} else
{
$shipid= $modelShipment->ship_id;
}
$htmlContent = file_get_contents('http://localhost/shepherdlogistics_v1.0/backend/views/shipment/invoicespackingdata.php');
$pdf->content = $htmlContent;
return $pdf->render();
}
invoicespackingdata.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Invoice</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.fontawesome.min.css">
<link rel="stylesheet" href="css/stylepdf.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<style type="text/css">
body {
font-size: 18px;
font-family: cambria;
}
.nopadd {
padding: 0px;
}
</style>
</head>
<body>
<div class="container">
<br>
<br>
<div class="">
<div class="col-lg-2 nopadd">
<img src="logopdf.png" alt="logo" width="100%">
</div>
<div class="col-lg-10">
<h1 style="font-size: 55px;font-weight: bold; padding: 23px 0px;">
SHEPHERD LOGISTICS CO. W.L.L.</h1>
</div>
</div>
</div>
</div>
As the demo states:
Any <style> tag will be skipped (you must use cssInline property for this)
If you have just a few styles to add to the pdf, you can pass it like this:
$pdf->content = $htmlContent;
$pdf->cssInline = '.class1 {color: red} .class2 {color:blue}';
But if you have alot of styles, you can also consider change the default cssFile to any file you want with the correct css. (by default, this property is #vendor/kartik-v/yii2-mpdf/assets/bootstrap.min.css