I'm currently working on a drupal theme but keep having problems with getting the theme to read the damn css file. I started off theming with the Framework theme, I tried organising the files on there for example creating a subdirectory to store the CSS file, change the setting in the .info file so it knows it's in the css folder, but it won't read the damn file.
Fast forward a few days and I've got 60% of my theme styled and layout-ed, so decided to port everything into a new theme folder rather than the Framework theme folder. Organised the folders and files, but again it won't read the CSS file whether I put it in a subdirectory or in the same directory as the .info file. It somehow worked once, but then went and hasn't worked again.
I've tried clearing the cache etc, but to no avail.
I'm working on a local wamp server. Drupal is latest version 7.
Any ideas how to fix this problem?
Thank you
Wich version of Drupal you are using? In Drupal 6 this works fine:
/* mytheme.info */
stylesheets[all][] = assets/css/master.css
stylesheets[all][] = assets/css/typo.css
This files are in my Theme folder
Folder: MYTHEME
File: mytheme.info
Folder: assets
Folder: css
File: master.css
File: typo.css
I know this is a bit late but maybe it will help someone else.
I'm using Drupal 7 and I attempted to add a javascript and stylesheet file in a custom module in the .info file.
module.always.js
and
module.always.css
It would load the first but not the second. I even put the stylesheet above the script in the info file and it would still just load the first file. Thought it was the directory and tried adding quotes around the file paths but that did nothing. Also thought it was the extra . in the file name but that didn't matter either.
The only way I could get both files to load was to remove them from the .info file and add a drupal_add_js and drupal_add_css for these files in the module_init() function.
No clue why that is the case but at least there is a work around.
Related
INTRO
I am new to php. I love that it allows me to change one header.php file and it updates all over the site.
IF all - index.php, header.php, style.css, article.php, homework.php files are in the ROOT folder, everything works like magic, I like it. I use:
<?php include_once "header.php"; ?>
at the top of index.php, article.php and homework.php and the header appears.
to load css a regular =
<link href="style.css" rel="stylesheet" type="text/css">
is enough to have in my header.php file, because all the files are in the same directory.
MY PROBLEM
When the amount of articles becomes too large and I decide I want to put those articles in different folders, that is when stuff gets confusing and I would like to know a proper way to solve it.
New website folder structure
C:\xampp\htdocs\articles\homework.php
C:\xampp\htdocs\views\header.php and style.css
C:\xampp\htdocs\index.php
C:\xampp\htdocs\articles.php
Now please help me how to make homework.php file to load the css from the header.php? I manage to load the header itself with
<?php include_once "..\views\header.php";?>
BUT the css file doesn't load for some reason.
I read something about "basenames", "site roots", but don't know how to properly set them up.
The perfect scenario
The perfect scenario would be if I could have a basename variable that I can change, so when I make my server live I can just change the basename to the appropriate new server directory and because all the header.php and other blog files were linked to that basename, everything would change automatically. I have done too many manual directory rewriting to do it once again, please tell me a way to automate it :)
Thank you a lot!
p.s!!!!!! Before I even post this question I realized that the header.php is trying to load views/style.css, which doesn't make sense, because the style.css file is in the same folder as header.php now.. Somehow basenames, site roots are a must here I believe...
You can specify relative paths such as ../css - means up one folder then look in css folder or ../../ - means up 2 levels then look in css folder.
../../main/css/style.css - would mean up 2 levels then look in main/css for the file style.css.
The problem with using / or ../ etc is that if you decide to change the location of the resource you still have to change all your paths. Using a var you can simply change it to reflect the new location.
with PHP you can also getcwd() and dirname() and realpath() to get a string representing a location, you can then set a base variable for your files and 'path' down from it.
This way you can use the same variable to locate a file rather than different relative paths depending on the level of the file calling it.
DIRECTORY_SEPARATOR is also useful for avoiding errors between / and \ with linux and windows OS. However I believe Windows and Linux will both resolve /
Personally I like to set path locations to commonly used files such as /includes in config.php then I can use that setting from anywhere
In summary you are just either discovering a path using PHP or setting a path as a variable
$path = 'c:/htdocs/mysite/includes/';
then using the variable as part of the path name when you access the file
$_SERVER['DOCUMENT_ROOT']
can also be useful to identify your site home folder
I can't find any good solution or im to stupid with php. How can i add wordpress editor to textarea's in my code.
http://refiddle.com/m10w
Thanks
Look at this function https://codex.wordpress.org/Function_Reference/wp_editor
The editor used by Wordpress is rcalled tinyMCE.-
for texarea fetching are you using advance custome field (ACF). if you want convert these textarea into default wp-editor Please find below link of github.
Add this you can easily use this.
Download editor here- https://github.com/elliotcondon/acf-wordpress-wysiwyg-field
Install as Plugin
Download .zip
Extract .zip and rename folder to 'acf-wp-wysiwyg'
Copy the 'acf-wp-wysiwyg' folder into your plugins folder
Activate the plugin via the Plugins admin page
Include within theme
Download .zip
Extract .zip and rename folder to 'acf-wp-wysiwyg'
Copy the 'acf-wp-wysiwyg' folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory
Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-wp-wysiwyg.php file)
include_once('acf-wp-wysiwyg/acf-wp_wysiwyg.php');
I want to change the directory of the style.css file in the pattern lab setup, how and where do I do this? I have a whole booststrap sass project setup already and I want patternlab to use the current files for this projects.
You can add css and javascript files in the following file:
source/_patterns/00-meta/_00-head.mustache
http://kohanaframework.org/3.0/guide/kohana/tutorials/clean-urls
following this tutorial, i managed to remove index.php from the url. I edited the "base_url" in bootstrap.php and the edited the .htaccess according to the tutorial. But now, I'm having a problem. my pages now can't load any of my css and js files included.
The picture there shows what happened.
Make your assets folder public. Do not store inside the application directory.
I have a site located at http://www.mySite.com. My html/PHP pages are located at http://www.mySite.com/index.php I have created a 'tabs' include file located at http://www.mySite.com/includes/tabs.html. And all is grand!
But I have started to need a bit more functionality and have added pre-coded pages/packages, like a blog. These packages are located in their own directories like http://www.mySite.com/blog.
The problem is the from the new package directories the links in the tabs include are no longer pointing to the correct URL because of the directory change. I understand why this is happening but cannot figure out a work around other than maintaining 2 separate tabs files, which seems wrong.
I had a very similar question that dealt with the css links and solved by adding a slash before the stylesheet path in the stylesheet link. Unfortunately it does not work in this situation also because in the different directory the include is '../includes/tabs.html'.
The tabs link is a standard html link:
<li>Home</li>
Again in my root directory files it works fine but if I put a file in a new directory like "http://www.mysite.com/newDir/index.php" the tabs are pointing to "http://www.mysite.com/newDir/tabURL.php" not "http://www.mysite.com/index.php".
Thank you again for your time,
Todd
All you need to do is update your links in the tab.html file to use absolute paths instead of relative paths.
<li>Home</li>
try including the tabs file using the full path on server no in your site directory e.g. www/mysite/includes/tabs.html