I have a problem where I want to redirect to a css file which stylesheet link is inside essentials.php in the main directory. however when including the essentials.php the browser redirects to the wrong url see image. how can i fix this?
I fixed my issue with a php variable $site which is defined as the url, in this way i can change the variable from localhost to the real site and is it easy to switch. In this way I do not have directory problems since the whole url is given.
$siteurl=localhost/project
href="<?php echo "$siteurl";?>/videos/watch?v=">
Related
after a great deal of time, I managed to set up my wordpress on localhost running xampp. The thing is now that I don't see any pictures or posts on my local copy. Via dev tools, I realised the path to the content looked like this:
wordpress.localhost/wordpress.localhost/wp-content/...
If it wasn't for the doubled "wordpress.localhost", I'd be able to see it. What might cause this? Is this due to an error in the database? How do I fix it?
Thank you!
Best wishes
Make sure you have properly set your site name under the settings > General > Site Address : http://wordpress.localhost
Images src must be like the following if images are inside your theme folder.
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images-folder/image.png" alt="">
Change the image path as per your requirements.
get_stylesheet_directory_uri() returns your active theme path.
I am trying to use images in css file in my laravel project that makes use of twitter bootstrap and Jason Lewis' Basset.
Now when I use a image in my css like
.div {
background: url('asset/img/photo.jpg');
}
I get the path to
http://localhost/asset/css/less/assets/img/photo.jpg
However the real path should be
http://localhost/~Username/laravelProject/public/asset/img/photo.jpg
The only way to achieve this is to use this url in my css
/../~Username/laravelProject/public/asset/img/photo.jpg
You guys would understand this is a no go if I have to move the site from local to server and have to change all the urls every time.. So Why is this not working properly? I am using this laravel starter site made by andrew13
startersite github
Last but not least.. this is the structure
The issue is that the path is bellow the css doc, relative file paths work by adding there files location to the beginning of the url, this means that it is looking for (Mypath)/asset/img/photo.jpg
(or: public/asset/css/asset/img/photo.jpg from what I can see)
Without a PHP server to return dynamic url's, sadly your only 2 options are:
Move the CSS to the root, or at least lower then the IMG
Use a absolute url
With php you have a few options, my favorite being a "Node" structure
How this works is placing a php file in the root folder that sets a constant of its location:
<?php
define('ROOTPATH', dirname(__FILE__));
?>
When ever you want to use this just include the file, and use ROOTPATH:
<?php
include 'TheFileName.php';
echo ROOTPATH,'/public/asset/img/photo.jpg';
?>
On most php servers this is already set to $_SERVER['DOCUMENT_ROOT'], but on a local host with will need to use a node.
Please note this is sudo code, some things may have to be changed
I'm improving a word-press web site. I need to include a file to a index WordPress theme, but that happen is really frustrating for me.
If I do in the index.php wordpress theme file, everything is ok:
include('myfile.php'); // myfile.php is of course in the same folder as index.php.
And the include is done properly.
But, if I try to move "myfile.php" to , for example, the father folder, the next thing should work, but no...:
include('../myfile.php');
This is for me really frustrating because doesn't have sense...
Next thing I have tried, setting all the absolute path:
include('http://example.com/myfile.php') but again, it doesn't work.
Wordpress has shortcuts for this. Try using
<?php get_template_part('myfile'); ?>
In fact, this is the right way to do an include
the absolute path must be the path of your file system.
you can try use realpath() php function, which solves the absolute path of the file through the parameter relative path.
see documentation http://php.net/manual/en/function.realpath.php
On certain pages drupal_get_path isn't working correctly (or it is and I've got the wrong function)
The base path is wrong
Example:
Image is supposed to be at
http://domain.com/sites/all/modules/pecapture/images/headline_dontmissout.jpg
But when on
http://domain.com/node/9
The URL is
http://domain.com/node/sites/all/modules/pecapture/images/headline_dontmissout.jpg
The same happens on the page
http://domain.com/admin/build/ and block edit page
How do I get the right path?
added base_path() to beginning of my paths...
base_path (http://api.drupal.org/api/base_path), if you use php code.
In html case, just add "/", like: /sites/all/modules/pecapture/images/headline_dontmissout.jpg
One problem: if you work on subfolder (Drupal installed in internal folder of main site): http://domain.com/subfoldersite, it will not correct, becase will remove "subfoldersite".
I created an Imagecache setting that just resizes to 125px wide. First issue is that the preview image is 404.
Then I want to print out an image via
<?php print theme('imagecache', 'imported_image', $node->picture, 'test', 'test', $attributes); ?>
'imported_image' being the preset and $node->picture is a correct path. The html prints out ok but the path it's trying load the image from does not exist. In sites/default/files/imagecache there is no folder with the name of the preset. Flushing the preset does nothing. The imagecache folder is writeable by everyone. This is on MAMP.
Anyone know what the issue could be?
Imagecache does not work when friendly url's are off. If this is the case, it can not 'find' the path to its folder in sites/default/files. When I turned them on, the folder with the name of the setting was created ok. The Imagecached images don't appear in here though. I'm putting it down to switching dev from Win to Mac, as a few people suggested on the Drupal forums.
posting last comment as an answer for ease in finding
Try to enable Lighttpd's "url.rewrite-if-not-file" directive
I posted it right here:
http://www.warp1337.com/content/solved-lighttpd-drupal-7-imagecache-images-are-broken-errorhandler404