I need to be able to call different CSS files in my local.xml within the reference name="head" to addItem with a full path from root (not from theme folder).
Right now I have
skin_csscss/skin.css
And that will be http://www.domain.com/skin/theme_name/css/skin.css
I need to be able to point to http://www.domain.com/skin/OTHER-theme_name/css/skin.css
Try doing something like this:
<reference name="head">
<action method="addLinkRel">
<rel>stylesheet</rel>
<href>http://www.domain.com/skin/OTHER-theme_name/css/skin.css</href>
</action>
</reference>
The second param to addLinkRel is your magic sauce. Checkout the block object located at app/code/core/Mage/Page/Html/Head.php for more details.
Related
I am trying to make something like "templates system" it might allow user to change site template. In admin panel for example.
My current files structure
-Controllers
-Models
-Views
--Templates
---DefaultTemplate
----css
-----style.css
----Index.cshtml
In default controller (home) i check current template name and show right view
private ViewResult TemplateView(string viewName)
{
return View($"~/Views/Templates/{GlobalSettings.CurrentTemplate}/{viewName}.cshtml");
}
And some template View (Index.cshtml)
.....
<link rel="stylesheet" href="~/Views/Templates/DefaultTemplate/css/style.css" type="text/css" />
.....
But I dont know how write correct path to my css\js\ images in right template forder.
I have tried
./css/style.css
#Url.Content("/css/style.css")
But in result HTML it is like mysite.com/css/style.css so i got 404 (not found)
I have also tried this
~/Views/Templates/DefaultTemplate/css/style.css
In this case i got 404 too.
So, can anybody help me? How to write correct URL to CSS, images, hs etc ?
The web.config file in the /Views folder restricts all access to files in the folder by default:
Add code to your web.config file:
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
Note: It's not good practice to store css files inside view folder.
I want to add custom CSS file for the Arabic Language.
I found how to add a CSS file to the local.xml like this
<action method="addItem"><type>skin_css</type><name>css/custom_style.css</name></action>
But I want to specify it for one language only.
Any idea how to implement this behavior?
In layout file you can use this code outside of default tag
<layout version="0.1.0">
<STORE_arabic>
<reference name="head">
<action method="addCss">
<stylesheet>css/custom_css.css</stylesheet>
<params>media="screen"</params>
</action>
</reference>
</STORE_arabic>
<default>
...
</default>
</layout>
'arabic' is your store code.
If you can work out a means of how, just add your stylesheet in regardless of language / locality and add a class to the body tag.
<body class="arabic">
and add that selector to your new stylesheet.
I was able to modify the original popup.pt and see changes in my instance, but when I try to override it by copying and renaming to archetypes.referencebrowserwidget.browser.popup.pt in my theme/(add-in) overrides folder I am unable to see my changes.
I overrode the path_bar class viewlet, following this tutorial. I attempted to follow the same logic for overriding popup.pt, but I was unable to get Plone to see the file in my configure.zcml.
configure.zcml:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="mytheme.theme">
<includeDependencies package="." />
<plone:static
directory="resources"
type="theme"
/>
<genericsetup:registerProfile
name="default"
title="mytheme.theme"
directory="profiles/default"
description="Installs the mytheme.theme package"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
<browser:viewlet
name="plone.path_bar"
manager="plone.app.layout.viewlets.interfaces.IAboveContent"
class=".customizations.PathBarViewlet"
permission="zope2.View"
layer=".interfaces.IMyTheme"
/>
<browser:page
name="login_main_template"
for="*"
permission="zope.Public"
template="login_main_template.pt"
/>
</configure>
While searching for a solution I found this Stackoverflow question - How to customize the popup.pt template from archetypes.referencebrowserwidget?. I added/:
<include package="z3c.jbot" file="meta.zcml" />
<browser:jbot directory="jbot_templates" layer=".browser.interfaces.IThemeSpecific" />
to my configure.zcml and removed the browser:viewlet from my previous attempt but I was still unable to get Plone to see my overview.
Which method do I need to use to override, the class viewlet, the z3c.jbot, or just the standard copy/rename method? I have read thru the Plone documentation multiple times, but still unable to resolve my issue. If I need to post any additional files please let me know.
Thanks in advance.
The z3c.jbot approach usually just works fine.
You have to be sure, that the file you place into to your jbot_templates folder has the right name.
The path to the popup.pt is archetypes/referencebrowserwidget/browser/popup.pt,
So in your case the filename must be archetypes.referencebrowserwidget.browser.popup.pt
Please make sure that your browserlayer .interfaces.IMyTheme is active on your site -> browserlayer.xml
How Can I appends a querystring parameter to each CSS and JavaScript include in the HTML to clear CSS and JavaScript cache.
I have tried
<action
method="addCss"><stylesheet>css/style.css?123</stylesheet></action>
and
<action
method="addItem"><type>skin_css</type><name>css/styles.css?123</name><params/></action>
.
But each time it returns a the base package like
http://www.example.com/skin/frontend/base/default/styles.css?123
not my custom theme directory .
How to solve this ?
This free extension should do what you want - works perfectly for me:
https://github.com/jreinke/magento-suffix-static-files
When you're adding a css file through xml layout updates, the addCss action (which realy just calls the addItem action with the type set to skin_css) is looking for a file path, not a url. While query strings are valid in urls, they aren't in file names. Magento sees that as an invalid parameter, gets confused and falls back to base/default.
I can think of 2 solutions for this. Unfortunately both are kind of hackey.
Move the css file to the base default theme. This works but it depends on fallbacks that might not stay the same in other versions of magento.
instead of directly inserting the css file, create a phtml template file with the html code to insert a css file. Then insert a core/template block with that new template file as its template in the layout xml. I've used this method on the sites i develop for to work around this problem.
Here's what we do:
<reference name="head">
<block type="core/text" name="link.tags">
<action method="setText">
<text>
<![CDATA[<link rel="stylesheet" href="/css/style.css?v=2">]]>
</text>
</action>
</block>
</reference>
Got this idea along with some other useful stuff from 5 Useful Tricks For Your Magento local.xml.
As an alternative, you can always just rename the file from style_v1.css to style_v2.css etc. whenever you make a change -- it has the same effect as changing style.css?v=1 to style.css?v=2.
as a follow up answer to this question i found the following (paid) magento extension which does what you require:
http://www.magentocommerce.com/magento-connect/clear-css-and-javascript-cache.html
I'm personalizing the MySite page with a custom controller and custom aspx, based in the original ones inside the SPSMSITEHOST folder. What I've done is copy them in my project, create a new controller .ascx and modify the copy of person.aspx and conten.aspx. Then I indicate in the the onet.xml the new path for my pages this way:
<NavBar Name="$Resources:spscore,SubNavTab_Overview_Text;" Url="person.aspx" />
<NavBar Name="$Resources:spscore,SubNavTab_Content_Text;" Url="personcontent.aspx" />
<NavBar Name="$Resources:spscore,SubNavTab_Tags_Text;" Url="_layouts/CustomMySite/thoughts.aspx" />
<NavBar Name="$Resources:spscore,SubNavTab_Colleagues_Text;" Url="_layouts/CustomMySite/MyContactLinks.aspx" />
<NavBar Name="$Resources:spscore,SubNavTab_Memberships_Text;" Url="_layouts/CustomMySite/MyMemberships.aspx" />
The thing is everything is working great. Every element in the quick launch menu is pointing to the right custom url and everything. Everything works great BUT the personcontent.aspx and I'm turning crazy here. The person.aspx is loaded in the same way and it works, why doesn't the personcontent.aspx? Should I change the url somewhere else?
Thanks!
I got with the problem. The url's are ok, but not the file type. It's necessary to mark them as Ghostable
<Modules>
<Module Name="Default">
<File Url="personcontent.aspx" Type="Ghostable"></File>
<File Url="blog.xsl"></File>
<File Url="tagprofile.aspx" Type="Ghostable">
<AllUsersWebPart WebPartZoneID="LeftZone" WebPartOrder="1">
...
This made the trick for me.