I am using SilverStripe as a CMS (http://www.silverstripe.com/services/why-choose-us/open-source-cms/) instead of Joomla or Drupal, and it has been a great experience for the most part so far. This problem however, is so strange that I am not even sure that SilverStripe has anything to do with it. Basically, links to CSS files that are set in a template are losing their leading slash when the markup is output to the browser. Obviously this can be very problematic.
This is the head section in the relevant template:
<!DOCTYPE html>
<html>
<head>
<% base_tag %>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=720, maximum-scale=1.0" />
<title>$Title</title>
<link rel="stylesheet" type="text/css"
href="/framework/admin/thirdparty/jquery-notice/jquery.notice.css?m=1342411326" />
</head>
The links are actually generated into the template dynamically, but I put this one link in myself to isolate the issue. Even manually added into the template, the link markup will end up with href="framework/admin/thirdparty/jquery-notice/jquery.notice.css?m=1342411326", the original link minus the leading forward-slash,/. Does anyone have an idea how this might happen? Doesn't matter if I'm in Chrome, Safari or Firefox, they all behave the same.
I have noticed I can "fix" the issue by breaking the whole document. If I add a character before <!DOCTYPE html>, the href on the css link is pointing at the root again with the leading slash. Is this because of the doctype, the base tag, or some strange combination of the two?
One of the stranger issues I've come across...
By default, SilverStripe leaves off the leading slash on purpose, and uses the base tag to ensure that the links point to the right place. The reason that this was done was to make it easier to build sites that would still work if the site is run in a sub-URL, so that a development site, for example, might be at http://localhost/mysite/.
This is the reason why everything goes to hell in a handbasket if you get rid of the base tag - SilverStripe was built expecting it to be there.
However, it shouldn't be stripping off leading slashes on URLs. The most likely thing that would be doing this is the ContentNegotiator class, and that would lead to different behaviour if you mucked with the doctype.
It used to be on by default but in 2.4 and 3.0 it should be off by default. What version of SilverStripe are you using?
Try appending an extra / at location from where the link is generated.
have you tried base tag?
If this won't work, you can try putting there whole link eg. http://website.com/framework...
Related
I need a little help here...
When I try to render a simple template in blade, I get a bad rendered html.
I have master.blade.php and home.blade.php inside views.admin directory.
<!-- master.blade.php -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Test Title</title>
</head>
<body>
Content
</body>
</html>
<!-- home.blade.php -->
#extends('admin.master')
The rendered HTML when I call return view("admin.home"); looks like this:
<html lang="en">
<head></head>
<body>
<meta charset="utf-8">
<title>Test Title</title>
Content
</body></html>
Any ideas of what is happening?
Thanks.
For me, this was caused by adding a ; to end of #extends('layouts.app')
I just spent about an hour trying to solve this, before deciding to make a new laravel app to paste new files over until it was fixed. It turns out my issue was because of a random character inserted into one of my config files (probably when trying to type in a url before realising my browser wasn't the active window). So if anyone can't seem to figure out why it isn't working after fixing their blade templates, check this.
Usually the case for the "" character appearing is that it has been introduced by using a non UTF-8 encoded text editor or was introduced in a different way. My suggestion would be to use something like Sublime Text or Notepad++ to create fresh versions of each of these three documents. This usually happens because of a copy/paste without realizing it or using a text editor that has "extra formatting" that you cannot see (e.g. Word). The character is ZERO WIDTH NO-BREAK SPACE (you can see more information here). So, it's not a Laravel Blade issue, it's that extra whitespace-type characters are being introduced by whichever text editor you're using.
I know the thread is old, but I faced this issue today and removing BOM helped me to fix it. One hint - if you are using PHPStorm, there is option to remove BOM, without need to copy the file and save it with another file editor. Just right click on the file and press "Remove BOM". Works like charm!
I know this is an old question, but for the sake of someone as me that had the same problem and came up to this page, I want to share what solved my problem.
As you may find in laravel's layout documents, it is stated that a master template should be used like this:
#extends('layouts.master')
#section('title', 'Page Title')
#section('sidebar')
##parent
<p>This is appended to the master sidebar.</p>
#stop
#section('content')
<p>This is my body content.</p>
#stop
My problem solved by adding #stop at the end of #section('content'). I hope this helps.
I am wondering why php does certain things twice, instead of once, when a certain meta tag is in the html portion of the file and the file is browsed by Firefox.
The code is like this:
<? /*...normal php code, including writing record to MySQL...*/
send('dan#example.com',$subject,$body);
?>
<!DOCTYPE html><html>
<!--PROBLEM on next line-->
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<head>
<title><?= $thisPage?></title>
<link href="<?= $cssURL?>css.freedom-and-purpose.css" rel="stylesheet" type="text/css" media="screen, projection" />
<?
include $dataPath . 'data.php';
?>
The result is TWO records written the database and TWO emails sent, whenever the page is called by FIREFOX. IE and Chrome not producing the problem.
There is a lot of other code in the program, but the reason I showed the portion above is that removing the line that starts with
<META...
solves the problem.
That meta tag is in there because one of the packages I run included it in their code sample.
So, what is that meta tag causes php to double do on DB-writes? And same thing on sending email?
Chances are this is actually a request for favicon.ico being caught by your main PHP file. Putting an empty file in favicon.ico or preventing your PHP from handling that URL should do the trick
enter code hereI would suggest you go through your code in some details and check its formatting.
Phil mentioned the meta tag about which I agree with. His suggestion of <meta charset="utf-8"> would be my preference.
Secondly the line sending the email looks odd. Single quotes aren't an option in php for data replacement, so the line send('dan#example.com','$subject','$body); would result in an email with the subject "$subject" and body just "$body".
Additionally send('dan#example.com','$subject','$body); appears to be missing a quote after $body.
I would advise you to move away from short php tags for opening and closing chunks of php <? ?> and get in the habit of <?php for clarity and to ensure the server you're using processes the code correctly.
Finally, I hope include $dataPath . 'data.php'; adds a </head> and a <body> to the html, as you're currently missing those too.
I can't seem to figure out how to add an extra "/" to the end of my website's URL without affecting the URLs that are referenced in the file.
So, I want to change the URL from
http://url.com/home
to
http://url.com/home/
without affecting the URLs that are embedded in the files.
Do you have any idea on how to do this?
Thanks,
Rob
You can use <base> tag in <head> section
<head>
<base href="http://mydomain.com/" />
</head>
With this all relative links will be prefixed with given base.
I'm trying to create a Wordpress template on one of my website pages, http://www.windowblindshadeshutters.com/blog/. The blog is now created, but I want to keep our original existing HTML template header so that it appears like the rest of the website, and then have the Wordpress template PHP file appear as the content on this page.
I started off just copying and pasting our original HTML header code in the top of the Wordpress PHP file, but it doesn't seem to be working right. I'm also wanting to include a doctype at the top, just like the original header, but I'm thinking that you shouldn't do this in a PHP file. My desired result would also require me to mix the original css file with the Wordpress css file, and it just seems like it's not working correctly.
So my question is, "How do I use an existing HTML header (that contains all of the original CSS styling) and insert it into a Wordpress theme effeciently?" Is it as easy as cutting and pasting code, transferring the CSS files, etc?
The original website header can be found at the root domain of the link above.
I'm not entirely sure if I got your question right, so I stand to be corrected: You are intending bring some HTML elements in your main site's header into the blog section's header which is residing in a Wordpress install on your server right?
Well, you're right in the sense that it is copy and paste effort, but I think the more important questions are: from which point on you should be adding those HTML elements in the header.php and what are the things that can or cannot be changed / deleted.
Perhaps a better way to go about this would be for me to tell you the standard things in a header.php and break it down.
<!--the mark up-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--the mark up-->
<head>
<!--meta-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!--meta-->
<!--document title-->
<title><?php bloginfo('name');?></title>
<!--document title-->
<!--links to scripts and stylesheets-->
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url');?>/style.css" />
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-1.6.1.min.js"></script>
<!--links to scripts and stylesheets-->
</head>
<?php wp_head();?> <!--do not remove-->
THE MARK UP
Okay, so the markup definition in the Doctype is definitely needed in the header.php otherwise the Wordpress theme will not know what it's marked up as. Moreover, the blog section is a Wordpress install on a sub-directory right? Chances are is that it is so it's not gonna be able to grab any information in the root directory where your actual main site is residing in.
META
You can copy the meta description tags or keywords tags from your actual main site and add them to the header.php
DOCUMENT TITLE
You can either choose to hard code and enter the title on the code level or change the blog title in the Wordpress Dashboard and leave it as <?php bloginfo('name');?>. This PHP tag automatically draws whatever is defined as the blog title in the Wordpress Dashboard as the document title. So if the blog title is different from your actual site's title then you will most probably see a discrepancy in that.
LINKS TO SCRIPTS AND STYLESHEETS
If you wish to include the stylesheet from your actual main site that is residing in the root directory, then you will have to change the href to an absolute link that goes there. For e.g. it will look something like <link rel="stylesheet" type="text/css" href="http://www.yourdomain.com/css/style.css" /> rather than <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url');?>/style.css" /> which only links to within your Wordpress install's theme directory. So suppose that you link that external stylesheet from the main site's location to the header.php by means of the method I just mentioned, you can go ahead and paste the necessary HTML content from your actual site's header and the styles should come out right - as long as the classes or ids remain the same.
ADD REQUIRED HTML CONTENT
So once that is all done, go ahead and add any required HTML content from your actual site's header after the <?php wp_head();?> tag. You can add it anywhere you want to and in any order you like to. Just be sure not to mess or overwrite any default template codes that the theme has.
Hope this has answered your question somehow.
You have to edit the header.php file.
After you finished the <header> section, you can start adding the page header.
This will be included in all WP pages / posts.
If you add wrapper start tags in haeder.php, don't forget to end them in footer.php
Read more about this here: http://codex.wordpress.org/Designing_Headers
A site I am working on that is built using PHP is sometimes showing a completely blank page.
There are no error messages on the client or on the server.
The same page may display sometimes but not others.
All pages are working fine in IE7, Firefox 3, Safari and Opera.
All pages are XHTML with this meta element:
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
It appears that I have fixed the problem by adding this PHP code:
header('Content-type: text/html; charset=utf-8');
I have read that this problem may be caused by XHTML, encoding, gzip compression, or caching, but nobody has been able to backup these guesses.
As the problem was intermittent I am not confident that my solution has actually solved the problem.
My question is, are there reproducible ways of having IE6 show a blank page when other browsers display content?
If so, what causes it and what solves it?
This is a content-type problem from IE.
It does not know how to handle application/xhtml+xml.
Although you write xhtml+xml, IE only knows text+html.
It will be the future before all agents know xhtml+xml
change your meta tag with content type to content="text/html;
Sounds like bug #153 "Self Closing Script Tag" bug in IE, which is well known to cause blank pages.
Due to IE's bug, you can NEVER code the following and expect it to work in IE.
<script src="...." />
(if the tag is self closing, you are in for a world of pain)
Instead, always code as;
<script src="...."></script>
I had a similar problem that was language specific - only the page with multibyte characters didn't show in IE6 and IE7. Turns out in these two browsers, the order of the Content-Type meta tag and the title tag is a big deal. So putting the tag (which contained Japanese characters) after the meta tag fixed the problem.
Not sure if this exactly matches your experience. It depends on which specific version of IE (including service packs) is being used.
A known rendering issue with IE6 SP2 & IE7 (both use the same rendering engine) is the existence of orphaned tags in your HTML. This may be an orphaned div or script tag.
<script language="javascript"> // no closing tag
alert('hello world');
<body>
hello world
</body>
The above renders just fine in IE6 SP1 and Firefox, but you will only see a blank page in IE6 SP2 & IE7.
There are certain other tags that must have a separate closing tag. Check that any <div> and <script> tags have an ending </script> or <div> tag, not just a closing slash at the end of the opening tag. Another one is <textarea>. You have to have both tags.
You can test if this is occurring with your site if you can View Source of your blank page and get the source html even though your page is blank.
You should serve pages with the Content-Type header as text/html to IE users. You don't need to change the meta tag, just leave it as application/xhtml+xml (IE will ignore it).
I got this bug due to a typing error.
I wrote the meta tag :
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
Thanks to you i corrected it to :
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
and i haven't the problem now.