I'm working on exporting my page to pdf using mpdf. The problem is, that I need my chords above the text. But every chord starts a new page and verse numbers aren't shown at all...
I'm getting song text from markdown via parses to html and than to pdf
css:
.wrapper{
display: inline-block;
position: relative;
margin-top: 4ex;
}
.chord{
font-weight: bold;
position: absolute;
bottom: 1.6ex;
}
.verse{
font-weight: bold;
position: relative;
margin-top: 3em;
}
.verse::after{
content: attr(number);
font-weight: bold;
transform: translateX(-120%);
position: absolute;
bottom: 0;
width: max-content;
}
php:
$object = \Spatie\YamlFrontMatter\YamlFrontMatter::parse(file_get_contents(__DIR__ . '/songs/' . $f));
$song = str_replace('<verse', '<p class="verse"', $object->body());
$song = str_replace('</verse>', '</p>', $song);
$song = str_replace('<wrapper><chord>', '<p class="wrapper"><p class="chord">', $song);
$song = str_replace('</chord></wrapper>', '</p></p>', $song);
$pdf->AddPage();
$pdf->WriteHTML($stylesheet, \Mpdf\HTMLParserMode::HEADER_CSS);
if ($object->matter('capo') != null) {
$pdf->WriteHTML('<div class="capo">Capo ' . $object->matter('capo') . '</div>', \Mpdf\HTMLParserMode::HTML_BODY);
}
$pdf->WriteHTML(
'<div style="position: absolute; width: 190.08mm; left: 53.46mm;top: 0; max-height: 265px">
<h1>' . $object->matter('title') . '</h1>
<h2>' . $object->matter('author') . '</h2>
<div class="song_body"><p id="song_text">' . $song . '</p></div></div>',
\Mpdf\HTMLParserMode::HTML_BODY
);
md file:
<verse number="1:"></verse><wrapper><chord>Am</chord></wrapper>I walk a <wrapper><chord>C</chord></wrapper>lonely road<Br>
Related
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
Trying to get this code to work. Code gets data by post method, echoes back data, then creates html file. Suspect I am not using tags correctly. I am confused on how to properly setup tags inside of php/ Original code by Stephan Borsay.
<?php
/* Some php above was removed. */
$WriteMyRequest=
"<!DOCTYPE html>".
"<html>".
"<head>".
"<meta name='viewport' content='width=device-width, initial-scale=1'>".
"<p>".
"<p>".
"<style>".
"body background-color #561c0e;
p color ffffff;";
"#header {
left: 550px;
top: 200px;
line-height: 40%;
font-size: 36px;
text-align: center;
position: absolute;
}";
"#wrapper {
width: 800px;
top: 325px;
left: 400px;
text-align: left;
font-size: 22px;
position:relative;
}";
"#column_container {
height: 800px;
width: 959px;
margin: 0 auto;
}";
"#leftcolumn {
float: left;
margin: 10px 0px 10px 0px;
padding: 10px;
height: 900px;
width: 300px;
}";
"#rightcolumn {
float: left;
margin: 10px 0px 10px 0px;
padding: 10px;
height: 900px;
width: 600px;
display: inline;
position: relative;
}";
"#link {
left: 175px;
top: 400px;
font-size: 28px;
text-align: center;
position: absolute;
}";
"</head>".
"</style>".
"<body>".
"<div id='header' style='color: #ffffff'>".
"<p>Environmental_Rain_Gauge.ino<br></p>".
"<p>Indianapolis, IN, US.</p>".
"</div>".
"<div id='wrapper'>".
"<div id='column_container'>".
"<div id='leftcolumn' style='color: #ffffff'>".
"<p>".
"<p>Last update: " . $var1 . "</p>".
"<p>Latitude is : " . $var2 . "</p>".
"<p>Longitutde is : " . $var3 . " </p>".
"<p>Temperature is : " . $var4 . "F.</p>".
"<p>HeatIndex is: ". $var5 . "F.</p>".
"<p>Humidity is : " . $var6 . "% </p>".
"<p>Dewpoint is : " . $var7 . "F.</p.>".
"</div>".
"<div id='rightcolumn' style='color: #ffffff'>".
"<p>".
"<p>Barometric Pressure is : " . $var8 . "in Hg </p>".
"<p>Difference since previous update : " . $var9 . "in Hg </p>".
"<p>Rainfall per Five Minutes is : " . $var10 . "mm</p>".
"<p>Rainfall per Hour is : ". $var11 . "mm</p>".
"<p>Rainfall per Day is : " . $var12 . "mm</p>".
"<p>Elevation is : 824 Feet</p>".
"<p></p>".
"<p>".
"<br><br>".
"</p>."
"</div>".
"div id='link' style='color: #ffffff'>".
"<a href='https://forum.arduino.cc/index.php?topic=606947.0' style='color: #ffffff' >Project Discussion: ESP32 Based</a></p>".
"</div>".
"</div>".
"</div>".
"</body>".
"</html>".
file_put_contents('dataDisplayer2.html', $WriteMyRequest);
?>
Online php checker produces error: PHP Syntax Check: Parse error: syntax error, unexpected '""' (T_CONSTANT_ENCAPSED_STRING) in your code on line 144
"".
When you have big HTML file data try to avoid using it as string as it creates conflicts and hard to understand. Also i see some mistakes in HTML. Nevermind as you are dont want to show the output and only want to save the html data in file. You can make use of Output Buffer in PHP which will simply save the output in buffer and then you can retrieve it to save it in file. So this way you don't need any variables and HTML string.
<?php
/*
ESP32: send data to your Domain
Uses POST command to send BME280 data to a designated website
The circuit:
* BME280
* Post to Domain
Original version of this code by Stephan Borsay
https://www.hackster.io/detox/send-esp8266-data-to-your-webpage-no-at-commands-7ebfec
*/
date_default_timezone_set("America/Indianapolis");
$TimeStamp = date("Y-m-d h:i:sa");
$var1 = 'testdata';
$var2 = 'testdata';
$var3 = 'testdata';
$var4 = 'testdata';
$var5 = 'testdata';
$var6 = 'testdata';
$var7 = 'testdata';
$var8 = 'testdata';
$var9 = 'testdata';
$var10 = 'testdata';
$var11 = 'testdata';
$var12 = 'testdata';
$var13 = 'testdata';
ob_start()
?>
<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1'>
</head>
<style>
body {
background-color: #561c0e;
}
p {
color: ffffff;
}
#header {
left: 550px;
top: 200px;
line-height: 40%;
font-size: 36px;
text-align: center;
position: absolute;
}
#wrapper {
width: 800px;
top: 325px;
left: 400px;
text-align: left;
font-size: 22px;
position: relative;
}
#column_container {
height: 800px;
width: 959px;
margin: 0 auto;
}
#leftcolumn {
float: left;
margin: 10px 0px 10px 0px;
padding: 10px;
height: 900px;
width: 300px;
}
#rightcolumn {
float: left;
margin: 10px 0px 10px 0px;
padding: 10px;
height: 900px;
width: 600px;
display: inline;
position: relative;
}
#link {
left: 175px;
top: 400px;
font-size: 28px;
text-align: center;
position: absolute;
}
</style>
<body>
<div id='header' style='color: #ffffff'>
<p>Environmental_Rain_Gauge.ino<br></p>
<p>Indianapolis, IN, US.</p>
</div>
<div id='wrapper'>
<div id='column_container'>
<div id='leftcolumn' style='color: #ffffff'>
<p>
<p>Last update: <?php echo $var1 ?> </p>
<p>Latitude is : <?php echo $var2 ?> </p>
<p>Longitutde is : <?php echo $var3 ?> </p>
<p>Temperature is : <?php echo $var4 ?>F.</p>
<p>HeatIndex is: <?php echo $var5 ?>F.</p>
<p>Humidity is : <?php echo $var6 ?>% </p>
<p>Dewpoint is : <?php echo $var7 ?>F.</p.>
</div>
<div id='rightcolumn' style='color: #ffffff'>
<p>
<p>Barometric Pressure is : <?php echo $var8 ?>in Hg </p>
<p>Difference since previous update : <?php echo $var9 ?>in Hg </p>
<p>Rainfall per Five Minutes is : <?php echo $var10 ?>mm</p>
<p>Rainfall per Hour is : <?php echo $var11 ?>mm</p>
<p>Rainfall per Day is : <?php echo $var12 ?>mm</p>
<p>Elevation is : 824 Feet</p>
<p></p>
<p>
<br><br>
</p>
</div>
<div id='link' style='color: #ffffff'>
<a href='https://forum.arduino.cc/index.php?topic=606947.0' style='color: #ffffff'>Project Discussion: ESP32 Based</a></p>
</div>
</div>
</div>
</body>
</html>
?>
<?php
file_put_contents('dataDisplayer2.html', ob_get_clean());
I did this with some test content and it is working fine.
Here are some references for Output buffer - https://www.php.net/manual/en/function.ob-start.php
As you can see in the picture, there is a box to the right with some text and a lot of white space.
My goal is to have the text under the pictures while I have 3 pictures in a row that are nicely aligned.
When I try this either the pictures aren't aligned anymore or the pictures aren't cropped anymore.
I wanted every picture with the same size and still sharp but, then this issue came up.
#content {
width: 100%;
max-width: 100%;
margin: 20px auto;
}
form {
width: 50%;
margin: 20px auto;
}
form div {
margin-top: 5px;
}
#img_div {
width: 30%;
margin-left: 2%;
margin-right: 1%;
margin-bottom: 3%;
border: 2px solid #d8680c;
float: left;
}
#img_div:after {
content: "";
display: block;
clear: both;
}
img {
float: left;
object-fit: cover;
width: 250px;
height: 250px;
}
#pictext {
word-wrap: break-word;
}
<div id="content">
<?php
while ($row = mysqli_fetch_array($result)) {
echo "<div id='img_div'>";
echo "<img src='fotopage\images/" . $row['image'] . "' >";
echo "<p id='pictext'>" . $row['image_text'] . "</p>";
echo "</div>";
}
?>
</div>
use class instead of using ID
ID must be unique and when you do the loop there will be some other divs with same ID
add it like this
<?php
while ($row = mysqli_fetch_array($result)) {
echo "<div class='img_div'>";
echo "<img src='fotopage\images/" . $row['image'] . "' >";
echo "<p class='pictext'>" . $row['image_text'] . "</p>";
echo "</div>";
}
?>
make sure to reflect them via JS or JQuery depends on what your are using
I was really unsure how to phrase this problem as it's something I've never encountered before.
My wordpress logo image which is set as a background using css is really buggy when hovering over it. Sometimes I can click it and sometimes I can't. Is this becuase I set the image in css and used text-indent to remove the standard text or is it something else?
Here's the live link. Try hovering over the logo to see excactly what I'm talking about.
I'm using a custom function in my functions.php to print out the logo and menu as seen here:
/**
* Prints out an ir-anchor with the site-title.
*
*/
function sircon_logo($echo = true) {
$htmlLogo = '';
if (get_bloginfo('name')) {
$htmlLogo = '<a';
$htmlLogo .= ' id="site-title"';
$htmlLogo .= ' class="ir"';
$htmlLogo .= ' href="' . get_bloginfo('url') . '"';
$htmlLogo .= ' rel="home">';
$htmlLogo .= get_bloginfo('name');
$htmlLogo .= '</a>';
}
if($echo) echo $htmlLogo;
else return $htmlLogo;
}
I call it in my header.php using this:
<?php sircon_logo(); ?>
And this is my styles:
/* image replace */
.ir {
background-color: transparent;
border: 0;
overflow: hidden;
}
.ir:before {
content: "";
display: block;
width: 0;
height: 150%;
}
/* logo */
#site-title {
position: absolute;
display: block;
top: 25px; left: 15px;
width: 157px; height: 64px;
background-repeat: none;
background-image: url('style/logo.png');
}
#site-title h1 {
margin: 0;
}
#site-slogan {
display: none;
}
#media (min-width: 500px) {
#site-slogan {
display: none;
width: 320px;
margin: 0 auto;
color: #fff;
font-size: 26px;
font-style: italic;
line-height: 1.1;
letter-spacing: -1px;
text-align: center;
padding: 14px 0 0 30px;
}
}
#media (min-width: 760px) {
#site-slogan {
display: none;
width: auto;
padding: 0;
margin: 0;
position: absolute;
top: 10px; right: 10px;
}
}
The Reason is the nav bar is overlapping the logo. So Apply z-index to the logo
#site-title {
z-index:300;
}
Set a z-index for your logo:
#site-title {
z-index: 500;
}
For further information check out this
Here are 2 solutions for your issue
Solution 1
#site-title {
z-index: 500;
}
Solution 2
#main-menu {
left: 220px;
right: 0;
width: auto;
}
Hope this helps you :)
I have a php file, and I am fairly novice at website development, but I've been helping a friend out. On the site we had some images that have been there for months, and recently they disappeared. I know the path to the images is still correct, and nothing with the coding has changed. Any ideas on why this could be broken? The pictures were in the div class = "graphicbuttons_cont"
$poli_more = do_shortcode('[pl_modal title="Buy & Sell" type="tab_links" label="<img class=\'\' title=\'Buy & Sell\' src=\'/wp-content/uploads/2013/02/buysell_icon.png\' /><br /><span>Buy & Sell</span>"]{27}[/pl_modal]');
$feed_back = do_shortcode('[pl_modal title="Feedback" type="tab_links" label="<img class=\'\' title=\'Feedback\' src=\'/wp-content/uploads/2013/02/feedback_icon.png\' /><br /><span>Feedback</span>"][gravityform id=4 title=false ajax=true field_values=\'store_page_id={28}\'][/pl_modal]');
$email_list = do_shortcode('[pl_modal title="email list" label="<img class=\'\' title=\'email list\' src=\'/wp-content/uploads/2013/02/email_icon.png\' /><br /><span>email list</span>"][gravityform id=1 title=false][/pl_modal]');
$desc_template = '<div id="header_container">' .
'<h1 style="text-transform: uppercase;" class="entry-title">' .
'Game on {0}' .
'</h1>' .
'</div>' .
'<div class="store_banner_class">' .
'<img style="height: 145px; width: 100%;" src="{33}" class="banner_img" />' .
'</div>' .
'<div class="graphicbuttons_area">' .
'<div class="graphicbuttons_cont">' .
$poli_more.
'</div>' .
'<div class="graphicbuttons_cont">' .
'<a href="https://maps.google.com/maps?saddr={25}&daddr={26}" target="_blank">
<img title="Directions" src="/wp-content/uploads/2013/02/getdirection_icon.png" /><br /><span>Directions</span>
</a>' .
'</div>' .
'<div class="graphicbuttons_cont">' .
'<a title="Follow " href="{29}" target="_blank">
<img title="Follow" src="/wp-content/uploads/2013/02/fblikeus_icon.png" /><br /><span>Follow </span>
</a>' .
'</div>' .
'<div class="graphicbuttons_cont">' .
$email_list.
'</div>' .
'<div class="graphicbuttons_cont">' .
'<a title="Review " href="{30}" target="_blank">
<img title="Review" src="/wp-content/uploads/2013/02/gplus_icon.png" /><br /><span>Review </span>
</a>' .
'</div>' .
'<div class="graphicbuttons_cont">' .
$feed_back.
'</div>' .
'</div>' .
Here's the style.css page,
#main_container {
padding: 30px;
background: #f1f1ef;
margin-top: -15px;
margin-bottom: 20px;
}
#store_image_container {
float: left;
width: 33%;
}
#gen_info_container {
float: left;
width: 61%;
margin-left: 60px;
}
#header_container h1 {
text-transform: uppercase;
float: left;
line-height: 32px;
font-size: 24px;
color: #ffffff;
padding-left: 10px;
}
#header_container {
background-color: #474647;
padding: 5px;
height: 32px;
margin-top: 20px;
}
#store_image_container img {
margin-bottom: 20px;
}
#data_gen_info {
margin-bottom: 22px;
clear: both;
}
#label_gen_info, .social-icon a {
font-size: 12px;
color: #37a8ab;
}
#label_notefrmowner {
font-size: 22px;
color: #B98BBF;
}
#data_notefrmowner {
margin-bottom: 30px;
}
#data_gen_info div table, #data_notefrmowner div table {
border: 0px;
}
#data_gen_info div table tr td, #data_notefrmowner div table tr td {
border: 0px;
}
#map_slideout {
display: none;
height: 410px;
}
#menu_cont {
float: right;
margin-right: 20px;
line-height: 32px;
}
#slider_button {
z-index: 1035;
height: 20px;
}
#click_btn {
background: url("viewstorelocator.png") no-repeat scroll 0 0 transparent;
padding: 0 196px 30px 0;
position: absolute;
right: 15px;
top: 0;
}
.tab_links, .tab_links:hover {
color: #ffffff;
margin: 0 10px 0 10px;
font-size: 12px;
text-transform: uppercase;
background-color: transparent;
text-shadow: 0 0 0 transparent; display: inline-block;
}
#sl_div img {
max-width: none;
}
#directionurl {
background: #37A8AB;
color: #ffffff;
box-shadow: none;
text-shadow: none;
border: 0px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
padding: 4px 10px;
font-size: 12px;
}
.social-icon {
float: left;
margin-right: 10px;
width: 31%;
}
.social-icon a {
color: #37A8AB;
}
.social-icon span {
display: inline-block;
width: 100%;
text-transform: uppercase;
}
.social-icon .social-icon-inner {
height: 130px;
}
.store_banner_class{
width: 100%;
overflow: hidden;
}
.banner_img{
height: 330px;
width: 100%;
}
.graphicbuttons_area{
background: none repeat scroll 0 0 #F1F1EF;
padding: 20px 0px;
text-align: center;
}
.graphicbuttons_cont{
display: inline-block;
margin: 0 15px;
}
.graphicbuttons_cont span{
color: #37A8AB;
font-family: "Montserrat";
font-size: 14px;
text-transform: uppercase;
This has nothing to do with your CSS and everything to do with your image locations...your urls in your php code are /wp-content/uploads/2013/02/fblikeus_icon.png and the url being printed in your live site are /portugal/wp-content/uploads/2013/02/fblikeus_icon.png
I would suggest figuring out why there is a discrepancy there. When I take /portugal/ out of your paths in Chrome's dev tools...your images show up fine.
Hello i am following this tutorial to make a php calendar
http://www.youtube.com/watch?v=l76uglZBjpk
I have three files
show_calendar.php
<!DOCTYPE html>
<html>
<head>
<link href="calCss.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<?php include ("calendar_start.php"); ?>
</body>
</html>
calendar start.php
<?php
//$showmonth = $_POST['showmonth'];
//$showyear = $_POST['showyear'];
$showmonth = 11;
$showyear = 2012;
$day_count = cal_days_in_month(CAL_GREGORIAN, $showmonth, $showyear);
$pre_days = date('w', mktime(0,0,0, $showmonth, 1, $showyear));
$post_days = (6 - (date('w', mktime(0,0,0, $showmonth, $day_count,$showyear))));
echo '<div id="calendar_wrap">';
echo '<div class="title_bar">';
echo '<div class="previous_month"></div>';
echo 'div class="show_month">' . $showmonth . '/' . $showyear . '</div>';
echo '<div class="next_month"></div>';
echo '</div>';
echo '<div class="week_days">';
echo '<div class="days_of_the_week">Sun</div>';
echo '<div class="days_of_the_week">Mon</div>';
echo '<div class="days_of_the_week">Tue</div>';
echo '<div class="days_of_the_week">Wed</div>';
echo '<div class="days_of_the_week">Thur</div>';
echo '<div class="days_of_the_week">Fri</div>';
echo '<div class="days_of_the_week">Sat</div>';
echo '<div class="clear"></div>';
echo '</div>';
/* Previous Month Filler Days */
if ($pre_days != 0) {
for($i = 1 ; $i<=$pre_days;$i++) {
echo '<div class="non_cal_day"></div>';
}
}
/* Current Month */
for($i=1; $i<= $day_count; $i++) {
echo '<div class="cal_day">';
echo '<div class="day_heading">' . $i . '</div>';
echo '</div>';
}
/* Next Month Filler Days */
if ($post_days != 0) {
for ($i=1; $i<=$post_days; $i++) {
echo '<div class="non_cal_day"></div>';
}
}
echo '</div>';
?>
and the css file calCss.css
#calendar_wrap {
width: 924px;
margin-left: auto;
margin-right: auto;
overflow: hidden;
}
.title_bar {
width: 100%;
height: 30px;
}
.previous_month {
float: left;
width: 308px;
height: 30px;
text-align: left;
}
.show_month {
float: left;
width: 308px;
height: 30px;
text-align: center;
}
.next_month {
float: left;
width: 308px;
height: 30px;
text-align: right;
}
.week_days {
width: 100%;
}
.days_of_week {
float: left;
width: 14%;
text-align: center;
}
.cal_day {
position: relative;
float: left;
margin-right: 4px;
margin-bottom: 4px;
width: 128px;
height: 95px;
background-color: #9C9;
}
.day_heading {
position: relative;
float: left;
width: 40px;
height: 16px;
padding: 6px;
color: #000;
font-family: Arial;
font-size: 14px;
}
.openings {
width: 100%;
clear:left;
text-align: center;
}
.non_cal_day {
position: relative;
float: left;
margin-right: 4px;
margin-bottom: 4px;
width: 128px;
height: 95px;
background-color: #CCC;
}
.clear {
clear: both;
}
my problem is show_calendar.php is not showing any css only text of the days of teh week and numbers in the month. Im not sure what i could be doing wrong, does anyone have any ideas? Im using xampp local server to view the php file. Thanks
I see just one small mistake:
you forgot one < here:
echo 'div class="show_month">' . $showmonth . '/' . $showyear . '</div>';
I tested it like that and works fine for me..
If you are using an IDE like ( dreamweaver ) for example , make sure that you set the Web URL for your localhost to (localhost/myProject) not (localhost/myProject/index.php) .. because it sometimes makes error , reaching the css directory .. I had that error , and that fixed it , hope it works for you :)
I've checked everything and found no reason why this shouldn't work. Probably your css file could not be loaded. You should check what you browser console says.
This is how you can debug this problem:
start the script in your browser
press shift + strg + j to start the developer tools (this shortcut works vor Forefox and Chrome f12 if you got IE)
select 'console'
check if there is an a loading error for your css
If you're on windows then the second problem source could be hidden file extensions. Maybe your filename isn't calCss.css but calCss.css.txt or simmilar. This is only a guess but I had this type of problem before. If it applies to your problem this is how you can display hidden file extensions