Using jScrollPane on a site. Wont scroll w/ scrollwheel. Whats wrong? - php

site example: http://ec2-107-22-119-73.compute-1.amazonaws.com/index.php/info/databases
Working Example: http://jscrollpane.kelvinluck.com/mwheel_intent.html
I cant get scrollwheel to work.
If you cant tell from the URL, my site is an expressionengine site. Using coldfusion and junk like that to build the pages.
anyone? (I tried searching for this issue, but no one seems to simply not be able to make scroll work.)

Ensure the paths to your JavaScript/CSS files are named appropriately and aren't throwing 404 errors.
The easiest way to ensure valid links to your assets is to use the {site_url} single global variable when linking assets in your templates:
<script src="{site_url}/script/jquery.mousewheel.js"></script>
<script src="{site_url}/script/jquery.jscrollpane.min.js"></script>
Which would result in the following:
<script src="http://example.com/script/jquery.mousewheel.js"></script>
<script src="http://example.com/script/jquery.jscrollpane.min.js"></script>
Since you're using ExpressionEngine's templates for your CSS — as opposed to flat files — you may want to give those template names a .css file extension.
So instead of:
<link rel="stylesheet" href="/index.php?css=site/master.v.1324329515" />
You'd have:
<link rel="stylesheet" href="/index.php?css=site/master.css.v.1324329515" />
This isn't absolutely necessary since EE will set the proper text/css MIME type based on the template type. However, it does make reading and debugging the source code easier, and is more of a standard practice.
Understandably, many beginners reference and borrow code from the Agile Records ExpressionEngine Theme that's available during new EE installations, so it's easy to recognize EllisLab's approach to markup and architecture — be it for the better or worse.
Bonus: remove the cache-busting timestamp (v.1324329515) in ExpressionEngine from CSS URLs, use the {path} variable instead of the {stylesheet} variable:
// With Cache-Busting String Appended
// http://example.com/index.php?css=site/master.css.v.1324329515"
<link rel="stylesheet" href="{stylesheet=site/master}" />
// Without Cache-Busting String
// http://example.com/index.php/site/master.css
<link rel="stylesheet" href="{path=site/master}" />

Related

what is the meaning of the following line in php smarty?

I'm new to smarty and I'm seeing this line
<link rel="shortcut icon" href="
{$system['system_url']}/themes/{$system['theme']}/images/favicon.png" />
This line is used to set favicon but they can use direct the image url "images/favicon.png" so why they used
It is a best practice to isolate different resources as much as possible. Referencing a static file such as a favicon directly creates a direct link between the web framework and web layout.
Using the types of variables you see in your example, makes the path address to the favicon dynamic so if the app where to be moved, or renamed, the links between layout and framework would still work without needing to manually change all path addresses.

HTML - set favicon

I set an icon like that:
<link rel="icon" type="image/x-icon" href="/media/icon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/media/icon.ico">
and I also tried this:
<link href="/media/icon.ico" rel="shortcut icon" type="image/x-icon" />
It works only in some parts of my website, but I don't know what I'm doing wrong. Is there something that I have to consider?
I use PHP and HTML. I don't know if it's coincidence or not, but it works with every HTML file and only with some of the PHP files.
Can anybody help me?
shivan
You'll need to make sure the URL (href) is valid for the page you are viewing.
Remember / is site level (/media/icon.ico = http://yourdomain.com/media/icon.ico).
Also make sure it is a valid .ico file. I recommend trying a .jpg file instead. (.png, .jpg, .gif and .ico are all valid favicon formats)
As well, depending on the icon size, it may not work in all browsers.
16x16 is the recommend size for favicons, but 32x32 may work as well.
Here is a link that should tell you everything about favicons: http://perishablepress.com/everything-you-ever-wanted-to-know-about-favicons/
If it only appears for your html pages and not your php ones, then you may be adding the link tag incorrectly or it may also be missing.
I suggest you use the developer tools of your browser (right-click anywhere on your page and choose Inspect Element - Chrome, Firefox) when you're on your php pages and check if you see the tag added correctly having the exact same path set there as in your html pages. Using developer tools you should also be able to hover over the link and it would tell you if the image existed or not.
I bet the path will be incorrect somehow depending on the placement of your php files versus the html ones and the icon.
Try accessing those pages from another browser. Also, try accessing them from a browser in incognito/private mode.
If you do see the favicon, try cleaning your browser's cache - it could be that something is left over from the last time you browse those pages (i.e. before you added the favicon to the HTML).
I had trouble getting this to work for me without using a direct link.
For example on my site: http://adamgressen.com/
I reference the image with a direct link:
<LINK rel="SHORTCUT ICON" href="http://adamgressen.com/favicon.ico">
You definitely want to clear your cache if you're testing locally because you may not see the changes for a while otherwise.

Codeigniter not displaying stylsheet when clicking on links

I just built a sit in Codeigniter, but when I click on a menu item the stylesheet breaks and it displays all of the content broken out on the page.
http://marciabrownproductions.com/
I uploaded it to a test server and all the links works perfectly.But when I uploaded the finished site ot my clients server the css issue starts. Is there something wrong with my clients server? Or is there a problem with how I coded the site? Why does it work on one server, but not the other.
Thanks!
First, I recommend using absolute paths instead of relative paths when referencing your assets. At the moment, they are being picked up with the index.php included.
So, let's say your link is http://domain.tld/index.php/home/actors, you should be calling your assets from their actual URLs - http://domain.tld/index.php/_/css/style.css would not work, for example. http://domain.tld/_/css/style.css, however, would work. (That's just a sample URL.)
I'd also recommend removing the index.php from your links, simply by using the htaccess RewriteEngine, and removing index.php from your app's config file.
Have a look at how your current source is being generated in a browser (right-click, View Source) to see what I mean.
Update:
Based on your comment, that may be an htaccess issue. Check to see if your hosting provider supports it.
In the meantime, put the index.php back in the app's main config file. However, leave your CSS asset link as it is. Make sure all your asset links look like this:
<link href="http://marciabrownproductions.com/_/css/styles.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='http://marciabrownproductions.com/_/js/jquery.validate.js'></script>
<script type='text/javascript' src='http://marciabrownproductions.com/_/js/effects.js'></script>
<link href="http://marciabrownproductions.com/_/css/bjqs.css" rel="stylesheet" type="text/css" media="screen" />
<script src="http://marciabrownproductions.com/_/js/bjqs-1.3.js"></script>
Your images are broken because their links are also including the index.php/home. You need to make sure that that is taken out. (What are you using to generate your links anyway?)

Yii including CSS and JS files

I've been reading on this quite some time...and i'm puzzled -
Can you help on what is the difference between:
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/some-file.css');
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/some-file.css
Is it a performance issue, or just different syntax?
Thanks,
Danny
registerCssFile always registers the file between the <head> tags, even if you call it somewhere in a view.
This is helpful if you care about HTML validation (a <link> in <body> is invalid), but still want to include a CSS file in a view.
registerCssFile actually aids performance, because the CSS is registered only when you want it (and need it).
The way you are using it, it is identical. To verify this, check the source of the page (in your browser) and check the statement that Yii::app()->clientScript->registerCssFile creates.
However, clientScript lets you control the position of the script in the HTML file. Check out: http://www.yiiframework.com/doc/api/1.1/CClientScript#registerScriptFile-detail and look for POS_HEAD, POS_BEGIN, POS_END.
What is probably more important is this: In the MVC philosophy, you want to have everything related to HTML-output in your view-file. Yii::app()->clientScript lets you add CSS and JS files from within your view files. And that is where you want it.

PHP Include Paths

I'm new to PHP and I'm having a problem when trying to link my CSS files using include.
Basically I need my files to link back to a certain directory no matter how far down the file is. I have tried using
<?php
include $_SERVER['DOCUMENT_ROOT'] . '/sysprogs/required/header.html';
?>
But header.html contains the links to my css files so the directory it ends up looking for the css files in is
http://localhost/SysProgs/software/CSS/style.css
instead of where I want it to go to which is
http://localhost/SysProgs/required/CSS/style.css
I hope that made sense and I hope you can help me
Thankyou for all your help everyone!
I would definitely not use <base>. I've run into many problems with this before. If you use <base>, ALL of your links will become relative to that base value.
Instead, I would recommend setting PHP constants for common directories. For example:
PHP Code:
<?php
define('CSS_DIR', '/SysProgs/required/CSS/');
?>
HTML Code:
<link href="<?php echo CSS_DIR ?>style.css" rel="stylesheet" type="text/css" />
One Idea
Use the full URL in header.html. This will be unambiguous and robust.
<head>
<link href="/FULL_BASE_URL/style/style.css" rel="stylesheet" type="text/css" />
</head>
Another Idea
Use the <base> header tag. This allows you to specify a base URL for links, including CSS, and may require the least work in the short term (see note below).
<head>
<base href="FULL_BASE_URL" />
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
More at w3schools
Note: As is noted in the comments below base may ultimately cause more confusion than it is worth.
I like to define both an absolute path and a webroot in a central place in your application:
<?php
define("APP_WEBROOT", "/myapp");
define("APP_ROOTDIR", "/home/www/example.com/htdocs/myapp");
?>
you can then "absolutize" the correct links like so:
<?php echo APP_WEBROOT; ?>/software/CSS/style.css
I prefer this
over <base> because that tag creates confusion and makes code harder to maintain in the long run
over using absolute paths /software/CSS/style.css because those make you unable to install your application in a subdirectory of your choice: You will always be bound to the root directory.
I run into this problem a lot when designing sites. When I have custom CMS, I use the following:
$basedir = "root_directory/";
$basedirPHP = $_SERVER['DOCUMENT_ROOT'].$basedir;
$basedirHTML = "http://".$_SERVER['SERVER_NAME'].$basedir;
I define $basedir so I can move the site to different subdirectories in the server without any effort. The $basedirPHP and $basedirHTML are so I can call on files either with php, or like you mentioned, when linking CSS, JS, etc.
If you're on wordpress, just use the good ol' bloginfo('template_directory'); to do the same in template files.
The first thing for you to understand, is your question has nothing PHP related. It is as simple as just filenames in your HTML questuon. Without PHP it will remain the same. Just use absolute path to your CSS file
And another thing to think of: consider to accept some questions.

Categories