HTML5Boilerplate build script CSS reference in PHP file - html5boilerplate

I'm trying to build my site with Html5Boilerplate and for the most parts it's going as I whish.
However, I'm still unable to get the CSS reference to update in my PHP file.
My folder structure is as follows:
css/style.css
page/header.php
Now in the header.php file I have:
<!-- scripts concatenated and minified via ant build script-->
<link rel='stylesheet' href='css/style.css'/>
<!-- end scripts-->
I would expect the built header.php file to have the following:
<link rel='stylesheet' href='css/a4cd4c0.css'/>
But unfortunately it is not updating the reference.
In the project.properties file I have: file.pages = page/* and it is stripping the comments in the header.php file, so I know the build script doesn't skip the file.
I have tried variaties, like:
<!-- CSS concatenated and minified via ant build script-->
<link rel='stylesheet/css' type='text/css' href='css/style.css'/>
<!-- end CSS-->
But this hasn't done a thing either . . .
Is there anyone who has tried to update their CSS files with Html5Boilerplate in their PHP files? What could I try to get the reference to be updated by the build script?
And my last question is: Could I let the build script update the reference, if I use the following line for including my CSS?
<link rel='stylesheet/css' type='text/css' href='<?PHP echo(CSS_PATH) ?>style.css'/>
EDIT:
By fiddling around in the build.xml file, I have not only got it working, but also with my php echo.
Around line 623 of the build.xml file I have changed the lines:
<replaceregexp match="<link rel=['"]?stylesheet['"]?\s+href=['"]?(.*)/${file.root.stylesheet}(?:\?.*)?['"]?\s*>"
replace="<link rel='stylesheet' href='\1/${css.sha}.css'>" flags="m">
to
<replaceregexp match="href=['"]?(.*\?>)${file.root.stylesheet}(?:\?.*)?['"]?"
replace="href='\1${css.sha}.css'" flags="m">
Hopefully this helps someone who is running to a similiar problem.

Depending on the version of HTML5Boilerplate you are using, the answer most probably lies in removing the comments in the .htaccess file specifically regarding 'Built-in filename-based cache busting'.
Here is the code section from HTML5 Boilerplate 4.1.
`<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>`
It would be inadvisable to edit or rework the build.xml file;
It is far more efficient to edit the .htaccess file.
You increase risk of not being able to future proof your application with updates and releases to HTML5 Boilerplate.

Related

CSS is not working when accesing a view through controller

I am working with codeigniter. But CSS is not working even I use base url() function.
< link href="< ? php echo base_url(); ?>
application/views/vehicle/css/bootstrap.min.css" rel="stylesheet" media="screen" />
If I just echo base url(), it outputs
http://localhost/codeigniter/
My css is in
C:\xampp\htdocs\codeigniter\application\views\vehicle\css
Can someone please help me with this?
Your css file should be in publicly approachable directory.
Application directory (application or APPPATH) is not publicly reachable.
So your CSS file should be somewhere next to index.php file of your application.
It is common to have assets/css path started in your website root:
-application
-system
-assets
--css
---vehicle.css
-index.php
-.htaccess
And if you make your web application code that uses CSS files dinamicaly regarding of route used, you can resolve it by adding more related subfolders:
-application
-system
-assets
--css
---vehicle
----style.css
-index.php
-.htaccess
This way, after url helper is loaded, you could reach css link with:
<?php echo base_url('assets/css/vehicle/style.css');?>
Eventualy you should include assets location in .htaccess file enabling Apache server to allow reading of it.
Maybe because of the ">" closing tag before "media".
Maybe you could try with relative path. So use as many "../" as needed to go back into parent folder untill you reach root dir (if your php file is in a sub-folder) and then add the path to the CSS file.

how to access folder of css files in magento

I am very new to magento. I am really confused how to load my own CSS files into magento. From some internet help, I came to know that, we have to save these CSS files at some location similar to
var/www/company_name/skin/frontend/default/magento_new_theme/css/folder
I also read that during installation of magento, we create all these folders or they are created automatically. (Please correct me, if wrong).
The thing is , I have no magento installed. I am accessing the magento system from website of my company. And I really want some help regarding, where, I have to go to get this var folder?
Note : It is magento but not magento go.
For using css from current theme you can use the following
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/newstyle.css') >" media="all" />
To add your own CSS files, navigate to your local xml file. It will be at app/design/frontend/package/theme/layout/local.xml
If it does not exist, make a copy from the default folder into the same location in your theme's folders. Open it up and inside the section <reference name="head"> include the below
<!-- Custom CSS -->
<action method="addItem"><type>skin_css</type><name>css/Custom_file1.css</name><params/></action>
<action method="addItem"><type>skin_css</type><name>css/Custom_file2.css</name><params/></action>
Provided these CSS files exist in your skin/frontend/package/theme/css folder then they will be added to the document's head.
use this:
<?php
$this->getSkinUrl('css/name.css');
?>
If you have using default skin package and skin template magento_new_theme then,then you can use
Mage::getSkinUrl('css/folder'); //for folder
Css file
Mage::getSkinUrl('css/folder/yourcssfile.css');
Assuming your Magento installation is at the root URI of your website, the path for CSS is "/skin/frontend/package/theme/css" and for images "/skin/frontend/package/theme/images", typically.
The 'package' and 'theme' names will be set in your Magento admin. The default package is 'base' and the theme is 'default', so that path would be "/skin/frontend/base/default/".
You will need to ask your Magento admin what the package and theme names are.

Magento admin css missing due to using file system path

I was unable to install a module using Magento Connect, getting a Connection Error try again later error. Following the instructions of the module developer I attempted to fix permissions in the document root with:
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod o+w var var/.htaccess app/etc
chmod 550 mage
chmod -R o+w media
It still didn't work so I ended up installing the module manually. I then logged into the admin backend and Magento was trying serve CSS files using the system file paths instead of URLs like so:
<link rel="stylesheet" type="text/css" href="/home/user/public_html/js/calendar/calendar-win2k-1.css" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/reset.css" media="all" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/boxes.css" media="all" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/custom.css" media="all" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/xmlconnect/boxes.css" media="all" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/menu.css" media="screen, projection" />
I immediately removed the extension and tried to match the perms from another server with a working Magento to no avail. I have also:
Cleared local, APC, and Magento caches
Looked in error logs (logging is enabled)
double-checked proper values of web/unsecure/base_url and web/secure/base_url in the DB
Rebooted, 3 times ;)
Minify is not being used. Merge CSS files are enabled, however I cannot figure out how to disable without the admin interface (save and navigation isn't working, even when I replace the correct values with Firebug). Any ideas would be greatly appreciated!
EDIT: As mentioned by #michael-hampton, this solution opens a serious security hole and shouldn't be used. Please don't use in production!
I ran into the same problem, and it happens that file permissions were not set properly.
In order to allow Magento to generate assets files, media directory must be writable by apache user.
So doing
chmod -R o+w media
will not necessarily allow apache to write in media directory, if apache don't own this directory.
You should check that apache actually own media directory, by checking first which user apache is running as, and then ajust permissions accordingly :
chown -R <apache_user> media
chmod -R o+w media
More information here: Magento Filesystem Permissions
A much simpler approach is to just head over to magento database and alter the table core_config_data manually. There should be an entry named dev/js/merge_files and dev/css/merge_files.
These two should hold values of 1.By setting these two values to 0, you'll get this fixed and your css and js files should be loadable again. tested in magento 1.5.x.
I ended up fixing it by being able to disable CSS merge by browsing to the relevant admin page and entering configForm.submit() in my java console to save the settings.
Not sure why CSS merge started using the file system paths of all a sudden, I wasn't changing anything associated with that (the module I was installing was for invoices). I've had a lot of randoms problem like this with Magento, it seems to require constant tinkering. I definitely am hesitant to recommend another client go with Magento again.
If you're using Fooman Speedster, just uninstall it from the Magento Connect Package Manager. Then, reinstall it.
Don't use the reinstall feature in the package manager, because it will not work.
Sometimes, you need to make sure that you have the media folder in your Magento root directory.

Access to restricted URI denied when linking to LESS css

I just downloaded the semantic CSS and was running the examples but saw the following error on Firefox
Access to restricted URI denied
file:///C:/semanticcss/examples/fixed/fixed.less
Below is the code in the example page
<!-- Stylesheets -->
<link rel="stylesheet" href="fixed.less" type="text/less" media="screen" />
<!-- Scripts -->
<script src="../../js/less-1.1.3.min.js" type="text/javascript"></script>
How can I get rid of this error?
This is on purpose. Local files may only read other local files in the same directory or sub-directories.
See https://developer.mozilla.org/en/Same-origin_policy_for_file%3a_URIs
Try
[sudo] npm install less -g
Then it shouldn't have any problems with the directories. My system (MBP) did the same thing until I did this. The main problem was that it doesn't know where the LESS compiler is located. You will more than likely need root privileges to run the command, hence [sudo] is system dependent.
Hope this helps.

Wordpress friendly URL's on Concentric/XO hosting?

I've recently installed Wordpress and can't seem to get the website to display friendly URLs no matter what settings I use inside the Dashboard or in an .htaccess file. I've tried numerous versions of Wordpress and still can't achieve what I need, despite succeeding on hosts other than Concentric/XO, any idea why?
Update: I released a plugin that does all of this for you. However, you still need to follow the steps for the .htaccess file. Have a look here: http://wordpress.org/extend/plugins/permalink-fix-disable-canonical-redirects-pack/
Follow these steps before you attempt to install WordPress for the first time. If you have already installed it, start over.
To get Permalinks working you need to create a .htaccess file, WordPress can't do this automatically on this host. Here is what the basic .htaccess file should look like:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Make sure you create this file using an editor that allows for unix formatting (like PSPad, or VIM, Textmate, etc.), using notepad will give you a parsing error - it has something to do with invisible end of file characters(CLRF). Make sure the last rule has a hard return after it, it's required. .htaccess files are cached for up to 15 minutes so you may have to wait for it to kick in.
Next you'll need to edit your wp-settings.php file so open that up in your editor. Add the following code right above the closing ?> php tag:
if(isset($_REQUEST['q'])) {
$_SERVER['REQUEST_URI'] = "/" . $_REQUEST["q"];
}else{
if (empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
} else {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . "?" .
$_SERVER['QUERY_STRING'];
}
}
If someone can write that block of code more cleanly feel free, I'm not an expert PHP programmer.
Once that block of code is in place you can proceed to run the install.
Now that WordPress is installed you'll have to do one more thing before you can start blogging:
Create a new file called: disable-canonical-redirects.php and upload it to the wp-content/plugins directory.
Drop this block of code into that file:
<?php
/*
Plugin Name: Disable Canonical URL Redirection
Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
Version: 1.0
Author: Mark Jaquith
Author URI: http://markjaquith.com/
*/
remove_filter('template_redirect', 'redirect_canonical');
?>
Now you need to enable that plugin, go to the Admin login page:
example.com/wp-login
Enable the plugin you created. That's it, you're on a horse.
Ask them whether they have mod_rewrite enabled.
To find out yourself, try adding a .htaccess file containing gibberish first:
sadölkasdfksdakföasldfg
if putting that onto the webspace, and then trying to access any page on it results in a 500 error, htaccess files get parsed.
Then try adding a "real" .htaccess file:
RewriteEngine On
if that works without a 500, then URL rewriting should be turned on.

Resources