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.
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 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 trying to create theme for Orchard CMS. The template I have wasn't made for it so I have some troubles displaying images from Layout.cshtml.
This is the current folder structure on my web server (theme folder structure only):
Theme/Content/Images/Image.jpg
Theme/Views/Layout.cshtml
Theme/Styles/Site.css
The following line doesn't display image (located in Layout.cshtml):
<img src="../Content/Images/bgBig.jpg" alt="Big background image" />
However, this line does display the image (located in Site.css):
background-image:url('../Content/Images/bgLines.png');
I believe the problem is that Layout.cshtml doesn't display the image from Theme/Views/Layout.cshtml, but from the other location. If someone knows what would be that location or how to override it I would be thankful.
I might be a little late, but this may be of help to others.
To get the current theme and then build an dynamic path (as opposed to an absolute path) use this:
WorkContext.CurrentTheme: Gets the current working theme ExtensionDescriptor.
Then give it to the Html.ThemePath URL builder:
Ex.
Html.ThemePath(WorkContext.CurrentTheme, "/Content/Images/SomeImage.png")
Have fun!
Best regards,
Tiago.
When adding images in Layout.cshtml you should use the full path to your theme (eg. /Themes/My.Theme/Content/Images/MyImage.jpg). Remember that the paths you provide in [img] tag are relative to the URL in browser, not the path on the server. In MVC those are almost never equal.
Layout.cshtml view file gets loaded as a part of every single request, so relative paths placed inside will almost always break.
Imagine you have two Orchard pages: site.com/mypage and site.com/something/mypage. Layout.cshtml gets rendered in both of them. Relative URLs working for the first will surely break when you access second one.
CSS stylesheets are loaded directly by specifying absolute path to the physical files in /Themes/YourTheme/Styles folder (default), so in this case relative URLs will work.
HTH
Thx Tiago for your solution. I think this is in fact the correct solution, as opposed to linking the full path which I think would require the Orchard site to be on the root of the domain.
The full image reference of the original question would look like this:
<img src="#Url.Content(Html.ThemePath(WorkContext.CurrentTheme, "/Content/Images/bgBig.jpg"))" alt="Big background image" />
I'm surprised that nobody's mentioned that you need the following web.config in the folder in which your images/scripts/styles reside (see the orchard docs)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<httpHandlers>
<!-- iis6 - for any request in this location,
return via managed static file handler -->
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers accessPolicy="Script,Read">
<!-- iis7 - for any request to a file exists on disk,
return it via native http module.
accessPolicy 'Script' is to allow for a managed 404 page. -->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule"
preCondition="integratedMode" resourceType="File"
requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
Additionally, as others have pointed out, this is the most reliable way of locating an image:
<img src="#Url.Content(Html.ThemePath(WorkContext.CurrentTheme, "/Content/Header.png"))" />
if you examine the source, it should show you where it's trying to find that image and failing. It's most likely the relative path it's having issue with, try an absolute path in the css to see if that's the issue. without the actual site, I can't know for sure.
Hi new to spark so this should be simple.
I'm converting an old webfoms page to mvc using spark.
I want to use the Base.Application to make up the src of a url
original markup
<img alt="" src="<%= Base.ApplicationPath %>images/screenshots/myImage.jpg" />
I've tried this in spark
<img alt= src=${ Base.ApplicationPath }+">images/screenshots/myImage.jpg" />
but no joy.
How do i do this in spark?
Not sure if you're aware of this, but Spark has a DefaultResourcePathManager that will automatically locate the Site Root if you prefix the resource with a tilde, so this should work just fine, and looks neater.
<img alt="" src="~/images/screenshots/myImage.jpg" />
There's an added bonus to using this technique as well....hold on to your shorts! Without changing your view, simply by making sure you use the tilde convention, you can dynamically redirect requests for your static resources to a content delivery network (CDN) or a completely different location - even an embedded resource inside a Spark Module .dll you compile for dll drop in deployment.
For example, to hook it up to a CDN, all you'll need to do is add the following kind of thing to your Spark Settings:
<resources>
<add match="/content/images" location="http://mycdn.com/youraccount/images"/>
<add match="/content/css" location="http://mycdn.com/youraccount/css"/>
<add match="/content/js" location="http://mycdn.com/youraccount/js"/>
</resources>
...and from then on those resources will be fetched from the new location instead. This is great for scenario testing locally, and the deploying to the cloud later.
Slight tweak of the syntax has sorted it.
<img alt="" src="${Base.ApplicationPath}images/screenshots/myImage.jpg" />