In CakePHP,if i give href links as href="/css/main.css" it is not refering to the css folder in the webroot. Only when I mention href="http://localhost/cake/app/webroot/css/main.css" the css gets applied.
<link type="text/css" rel="Stylesheet" href="/css/main.css" media="screen,projection" />
This does not apply the specied css.
What is the reason for this?
Why is the code not identifying the correct folder?
Because it starts with a /, it is treated as an absolute path (from the root of the site). The browser translates it to
http://localhost/css/main.css
You can either specify the correct absolute path
/cake/app/webroot/css/main.css
or the full path
http://localhost/cake/app/webroot/css/main.css
or a relative path, for example
../css/main.css
echo $html->css('main');
BOOK
API
Why are you not using core helper? It will generate required path to CSS file Inserting Well-Formatted elements
And check main configuration file(/app/config/core.php), maybe you are not using mod_rewrite. Check core.php for commented this line Configure::write('App.baseUrl', env('SCRIPT_NAME'));
If your absolute URL looks like
http://localhost/cake/app/webroot/css/main.css
and your URL is
/css/main.css
I suppose the browser translates the URL you gave to
http://localhost/css/main.css
(you can check that with Firebug, "net" tab for instance)
If that's the case, you should :
use a relative URL with no leading /
use an absolute URL that refers to the root URL
But, in my opinion, using the URL that starts with 'http://' is the best way to be sure that your CSS inclusion is always OK, no matter which directory or URL you are into...
A function like this to define a BASEURL allows you to only update in one place.. I use something like...
define("DEVELOPMENT", true);
function setReporting()
{
if (DEVELOPMENT)
{
define("BASEURL", "http://localhost/localDir", true);
error_reporting(E_ALL);
}
else
{
define("BASEURL", 'http://' . $_SERVER['SERVER_NAME'], true);
error_reporting(0);
}
}
setReporting();
When you deploy cake, the url should just be /css/main.css as the server's DocumentRoot will point to the cake/app/webroot directory.
I suggest reading this article from Cake's online docs for more info. Note that this article refers to the 1.1 version of Cake, but should work in 1.2 as well.
Good luck!
Related
<Link to={`channels/${channel.channel_name}`}> {channel.channel_name}</Link>
Let's say the user is watching a video (current url = 'localhost:3000/videos/1') and they want to click on the channel's link, when they do I want to send them to 'localhost:3000/channels/Lun', but for some reason the links just stack like this 'localhost:3000/videos/1/channels/Lun'... I treid using the replace keyword but that doesnt work too, any help is appreciated!
Need to change the link like this.
<Link to={`/videos/${//route here}`}>
I need to remove the part of image, css and js urls so that I would keep everything that goes after "."
For example,
https://test.com/en/images/footer-inst-icon.svg
I would like to have only "svg" in another column
Here is the link to the file https://docs.google.com/spreadsheets/d/1VJPQzkgZCTaKCgRbstVFDCwycZFfCbSL1ENXPYcioNo/edit#gid=0
Try below formula (see your sheet)-
=ArrayFormula(TRIM(RIGHT(SUBSTITUTE(A2:A,".",REPT(" ",100)),100)))
You can also use REGEXEXTRACT() like
=ArrayFormula(REGEXEXTRACT(A2:A,"\w+$"))
I'm setting up a wagtail site which needs to display all links as full urls since the pages will also be used as email templates.
Wagtail version 2.5.1
My main issue is document links which are embedded in RichTextFields. The current work around is to have them inserted as external links after they upload the documents.
I've looked at features.register_link_handler but am unclear on how to deal with Document links. I'm assuming that it will need to be in wagtail_hooks.py register_rich_text_features somehow.
I ended up creating a register_rich_text_features link handler for this in wagtail_hooks.py
class DocumentFullLinkHandler(DocumentLinkHandler):
#classmethod
def expand_db_attributes(cls, attrs):
try:
document = cls.get_instance(attrs)
current_site = Site.objects.get_current()
document_url = (
document.url
if document.url.startswith(settings.PATH_PREFIX)
else f"{settings.PATH_PREFIX}{document.url}"
)
full_url = f"https://{current_site.domain}{document_url}"
return f'<a href="{escape(full_url)}">'
except (ObjectDoesNotExist, KeyError):
return "<a>"
The real answer is to Upgrade to Wagtail 2.7 and then set
WAGTAILDOCS_SERVE_METHOD = "direct" in the settings.
This will provide the direct document when using remote storage.
#sw12k I tried to apply your same solution and I couldn't make it work, but... I think I found a much simpler solution that actually made the trick.
In the html template, when you render your RichTextField I moved from:
{{ page.description|safe }}
to this:
{{ page.description|richtext }}
And now document links are well formatted and download links work fine.
Hope it helps.
I am a new developer and I want to implement a popup screen in Drupal 7.
I found a code online and it works, except for the "link rel" code the example has at the <head> section.
The code is the following:
<link rel="stylesheet" href="http://www.jacklmoore.com/colorbox/example1/colorbox.css" />
I tried opening this link and adding the whole code at the styles.css file, but the popup appears without any style.
Is there a way to do it correctly?
If you added the CSS content to your CSS file maybe you should clear the CSS cache to see changes.
You also should check the selectors match to the CSS rules (for instance with Firebug in Firefox browser).
Or in the template.php you can add external CSS in this way:
function mytheme_preprocess_html(&$variables) {
`drupal_add_css('http://www.jacklmoore.com/colorbox/example1/colorbox.css',`
`array('type' => 'external'));`
}
I am using AngularJS to develop an Chinese website. I used ui-router to manage the URL links, and the params for the URL is in Chinese.
Here is the code, schoolName is an variable in controller, and the value is Chinese characters:
<a ui-sref="showSchools({name:schoolName})" > 查找</a>
The problem is it will generate URL like:
http://localhost:8080/#/showSchools?name=%E7%A6%8F%E5%BB%BA%E7%9C%81%E9%97%BD%E4%BE
But i want the link to be like:
http://localhost:8080/#/showSchools?name=第一中学
I tried encode param into utf8 with encodeUri filter: https://github.com/rubenv/angular-encode-uri, but it does not work.
Is there anybody know how to show Chinese characters in the URL?
This might be too late but I thought it might help.
I too had this same issue while trying to display chinese characters in the url while testing a angular app (with ui-router) with localhost.
The urls used to appear as below:
http://localhost:56066/#/map/%E6%B1%9F%E8%8B%8F
But as soon as I added the below line to clean up the url:
$locationProvider.hashPrefix('!').html5Mode(true);
The urls now appear as below (which is what I hoped they would look like):
http://localhost:56066/map/黑龙江
I haven't yet figured out why cleaning up the url helped!