1

Hey guys I have created a plugin with an accompanying Stylesheet which I am adding to the page via

class SitemaphtmlPlugin extends BasePlugin
{

function init(){

     craft()->templates->includeCssResource('sitemaphtml/css/sitemaphtml.css');
}

however the link being generated is prefixing the path with cpresources/ making it 404.

/cpresources/sitemaphtml/css/sitemaphtml.css?x=xXhFyszUs 

how can i overcome this this?

Cheers

2
  • Are you trying to get the CSS file to load in the control panel or on the front-end of a site?
    – Brad Bell
    Mar 15 '16 at 17:15
  • Hi thanks for the reply, I am trying to get the CSS to load on the front-end of the site. Cheers
    – jmack
    Mar 16 '16 at 9:29
2

Is your css file located in the /resources/ folder of your plugin? So your path should be something like:

<plugin folder>/resources/css/sitemaphtml.css

I've tried it myself and whilst you do get the /cpresources/ part of the Url in your markup, the CSS file is loaded on the front end.

EDIT: If you take a look in the docs, it says the following:

By default, Craft will search for the resource file in its own craft/app/resources/ folder. If it can’t find the file there, it will check if the first segment of the resource path is set to a plugin handle. If it is, Craft will look for the resource file within that plugin’s resources/ folder.

2
  • That was it all along, thank oyu very much for your help.
    – jmack
    Mar 16 '16 at 13:17
  • No worries, I've done it myself :) Mar 16 '16 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.