I added new configuration settings to my Liferay theme inside the file liferay-look-and-feel.xml
<setting configurable="true" key="show-navigation" type="checkbox" value="true" />
In the control panel I can see the setting with show-navigation label.
I want to translate it to Show the Main Navigation using Language.properties inside the theme.
Then to accomplish this in my theme I added this files (theme\docroot\WEB-INF\src\content):
Language.properties
Language_en.properties
Language_fr.properties
Which each file contains the translation as so:
show-navigation=Show the Main Navigation
then in theme\docroot\WEB-INF\ I added liferay-hook.xml
<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
<hook>
<portal-properties>portal.properties</portal-properties>
<language-properties>content/Language*.properties</language-properties>
</hook>
But it doesn't work. If I perform the same procedure for a portlet it works.
Why?
It's the name: You don't use content/Language*.properties, but just content/Language.properties. Otherwise I believe you're on the correct way to solve the problem, it's just this little detail
Related
We use one theme for our desktop web page and another for responsive/mobile version of the site. But for mobile we don't always want to show images and it would be good if we can restrict it from the template, not just hiding it with CSS (because it still loads the image, just does not show it).
For that I need to get liferay current active theme ID or name so I can add simple if statement in the template.
#if(${themename} == "desktopTheme")
<img src="foo.jpg"/>
#end
Does anyone has ideas how to get it? I searched and checked lots of liferay's forums, but didn't find anything.
Thanks!
My advice would be to not hardcode the theme's name, but use theme settings that are readily available. Just configure your theme to be "desktop" or "mobile" style and check for this property. This way you can cover many different themes without hardcoding particular ones.
Also, the various ThemeDisplay.getTheme*() methods will help you to get the required information almost anywhere you are.
Here's some untested pseudo code for your themes (I just typed it here, never compiled/deployed, you might want to add null-checks for the VM stuff)
<?xml version="1.0"?>
<!DOCTYPE look-and-feel PUBLIC "-//Liferay//DTD Look and Feel 6.0.0//EN" "http://www.liferay.com/dtd/liferay-look-and-feel_6_0_0.dtd">
<look-and-feel>
<compatibility>
<version>6.1.0+</version>
</compatibility>
<theme id="my-desktop-1" name="My First Desktop Theme">
<settings>
<setting key="mobile" value="false" />
</settings>
</theme>
</look-and-feel>
<?xml version="1.0"?>
<!DOCTYPE look-and-feel PUBLIC "-//Liferay//DTD Look and Feel 6.0.0//EN" "http://www.liferay.com/dtd/liferay-look-and-feel_6_0_0.dtd">
<look-and-feel>
<compatibility>
<version>6.1.0+</version>
</compatibility>
<theme id="my-mobile-1" name="My First Mobile Theme">
<settings>
<setting key="mobile" value="true" />
</settings>
</theme>
</look-and-feel>
And then, in VM or JSPs or other code:
#if( ! $themeDisplay.getSetting("mobile"))
## more resources, desktop only, here.
#end
#if( $themeDisplay.getSetting("mobile")
## mobile only stuff here.
#end
And finally you might also want to consider to use the Device Detection API to determine the current device's actual capabilities on a far finer granularity
Suggest you to use themeId whis is also unique. its something the following:
xxx_WAR_xxxtheme
#if($themeDisplay.getThemeId().equalsIgnoreCase("<dektop theme id>"))
### your logic here
#end
HTH
I have a Jsp that dynamically needs to get included in entire project as user opens any jsp. i.e. As a user opens a jsp my jsp should automatically gets included.
I have written this in web.xml in Tomcat
<jsp-property-group>
<url-pattern>/webapps/ROOT/html/*.jsp</url-pattern>
<url-pattern>*.jspf</url-pattern>
<el-ignored>false</el-ignored>
<scripting-invalid>false</scripting-invalid>
<is-xml>false</is-xml>
<include-prelude>/WEB-INF/jsp/tracker.jsp</include-prelude>
<!-- <include-coda>/template/coda.jspf</include-coda> -->
</jsp-property-group>
I had kept my jsp in tomcat under WEB-INF/jsp/ and i want to include it into every porject as it contains a code that tracks log for user.
Or any other way to make this happen.
Thanks.
There is one more way to include your JSP for the whole portal and i.e. the dockbar.
You can create a hook and include your jsp in the /html/portlet/dockbar/view.jsp using either <jsp:include /> or <liferay-util:include /> or simple <%# include file="" /> (this would be static).
<jsp:include page="/jsp/yourJSPPageToBeIncluded.jsp" />
OR
<liferay-util:include page="/jsp/yourJSPPageToBeIncluded.jsp" />
OR
<%# include file="/jsp/yourJSPPageToBeIncluded.jsp" />
Note: the path may differ depending on where you will be putting the JSP.
Why I am choosing dockbar is because it is present on all the portal-pages of liferay. This won't work if you are opening a pop-up like configuration pop-up or look-and-feel pop-up or other custom dialog pop-ups since dockbar is not present in the pop-up. For using in pop-ups you would have to override portal_pop_up.vm in your custom-theme and write the code as suggested by #VikasV
$theme.include($themeServletContext, "/jsp/yourJSPPageToBeIncluded.jsp")
There are two ways for this.
Simple way is to include your JSP in the Theme. When your Theme is applied to your project, and when Theme is rendered, any pages in your project will render this included JSP.
Code sample below. This has to be placed in vm file(navigation.vm).
$theme.include($themeServletContext, "/jsp/yourJSPPageToBeIncluded.jsp")
Here, JSP folder is placed directly inside Theme war.
Other way (tedious one), is to include this JSP in each and every JSP page that you want this to be included.
Use <jsp:include> element for this.
Some references,
Ref1
Ref2
In Sharepoint 2007, I have created a layout. As you know when the user creates a page he chooses a layout from a listbox.
When you select a different element in the listbox, there is a preview image that changes on the left.
I thought this was controlled by the node PublishingPreviewImage in the xml of the layout. I have verified that the image exists in that place.
It is not working.
The code I use is:
<File Path="TituloTextoCtrl.aspx" Url="TituloTextoCtrl.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists ="TRUE">
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/titulotextoctrl.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/titulotextoctrl.png" />
<Property Name="MasterPageDescription" Value="Plantilla Titulo+Texto+Control" />
<Property Name="ContentType" Value="Titulo+Texto+Control" />
<Property Name="PublishingAssociatedContentType" Value=";#Vialibre_ContentTypeGeneral;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39005215cca003b74e479baa123eb1dc5702;#" />
</File>
You also need XML to provision the image:
<Module Name="MyPreviewImages" Url="_catalogs/masterpage" IncludeFolders="??-??" Path="" RootWebOnly="TRUE">
<File Url="titulotextoctrl.png" Name="Preview Images/titulotextoctrl.png" Type="GhostableInLibrary">
</File>
</Module>
first of all upload yor layout page image in site collection document library or picture libary. Then Go to site actions--> site settings-->Galleries-->master pages and pagelayouts-->. In pagelayouts you can see your new layoutpage.
choose edit properties of your layoutpage there you can see the properties of that layout page. There is one column called preview image, give the url of image there that you already uploaed in the docu libary. click on Ok, now you have got preview image of your layout page.
Thx to Rich Bennema and Hojo for answering, there are right, but at the same time, my problem is that this layouts were deployed, and when I deploy again changing the PublishingPreviewImage, the layout is not updating. So my problem was a problem of controlling events so that everytime that I deploy the layouts are recreated in case there is changes.
This I know because it has worked for new layouts.
So for those who try this. Use the code I have provided with the one of Rich Bennema to upload the image.
I have created a CustomAction feature to add a button to the "Actions" menu on a list. When I don't specify the ControlAssembly/ControlClass attributes then the button shows up. When I specify those attributes the button does not show up. I have tried adding a matching SafeControl element in the site web.config. I am using VSeWSS.
UPDATE - removed link to other question - not sure how i did that.
My question is can anyone tell me why my CustomAction button is not showing up when I specify the ControlAssembly and ControlClass attributes ?
UPDATE 2 - RegenConfigTemp actually does inherit from WebControl, sorry! My machine with web access is different from my dev machine and there is no way to move files between them short of burning a CD.
here are my files:
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<Solution SolutionId="GUIDHERE" xmlns="http://schemas.microsoft.com/sharepoint/">
<FeatureManifests>
<FeatureManifest Location="RegenConfigTemp\feature.xml" />
</FeatureManifests>
<Assemblies>
<Assembly Location="WebFeature.dll" DeploymentTarget="GlobalAssemblyCache" />
</Assemblies>
</Solution>
feature.xml
<Feature Id="GUIDHERE" Title="RegenConfigTemp" Scope="Web" Version="1.0.0.0" Hidden="FALSE" DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="RegenConfigTemp\Module.xml" />
</ElementManifests>
</Feature>
Module.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements Id="GUIDHERE" xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="GUIDHERE"
RegistrationType="List"
RegistrationId="1981"
GroupId="ActionsMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
Title="Regenerate List Contents"
ControlAssembly="WebFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=myPKTokenHere"
ControlClass="WebFeature.RegenConfigTemp"
></CustomAction>
</Elements>
RegenConfigTemp.cs
using System;
using System.Runtime.InteropServices;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebControls;
namespace WebFeature
{
[Guid("GUID HERE MATCHES 1st GUID in Module.xml")]
public class RegenConfigTemp : WebControl
{
protected override void OnLoad(EventArgs e)
{
this.EnsureChildControls();
base.OnLoad(e);
}
protected override void CreateChildControls()
{
base.CreateChildControls();
}
}
}
I added the following to the web.config
<SafeControl Assembly="WebFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=myPKTokenHere" Namespace="WebFeature" TypeName="RegenConfigTemp" Safe="True" />
Turns out the problem was in Module.xml. I was missing the 'equals' sign after 'Version' in this (corrected) line:
ControlAssembly="WebFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=myPKTokenHere"
I got on the right trail b/c I discovered Sharepoint's diagnostic logging, and the first comment on this blog: http://blog.lostparticles.net/?p=23 was my problem exactly.
Thanks for y'alls help.
UPDATE: I had to fix web.config line as well. I ended up putting the safecontrol line in the manifest instead of directly in the web.config; thanks JMD. (BTW, why doesn't VSeWSS do that for me, when it does for web parts?)
Are you sure that your code is supposed to render anything? Which class are you inheriting from and where is your render code? Have you checked the SharePoint log for any exception?
This is not an answer to your question, but you can place your SafeControl tag in the manifest instead of the web.config.
Surely RegenConfigTemp should be inheriting from something? At present you're not adding any controls, so if you're overriding an empty control that would be why you're not seeing anything. If nothing else, try setting a breakpoint or adding some diagnostic tracing to CreateChildControls() to see if the code is executing.
I have two SharePoint features, each implemented identically (see below), that add controls to a delegate control in the header of my pages. One of the controls depends on the other (one is the jQuery library, and the other depends upon jQuery), however, when the controls are rendered, the order of the controls is incorrect. How do I specify the order that these controls are rendered in?
The control (both are identical, except that they reference a different .js file):
<%# Control ClassName="MyScriptControl" %>
<script type="text/javascript" src="/_layouts/MyScript.js"></script>
feature.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="AA9D59AC-D53E-4338-9B52-CD39F2A8C31A"
ActivateOnDefault="true"
Title="My Feature"
Description="Does something."
Scope="Site" Version="1.0.0.0"
Hidden="FALSE"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="MyFeature\Elements.xml" />
</ElementManifests>
</Feature>
Elements.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"
Id="24A4BB9A-9636-4a73-B3A5-35661DE19902">
<Control Id="AdditionalPageHead"
ControlSrc="~/_controltemplates/MyControl.ascx" />
</Elements>
The output on the page (jQuery is deployed before DependsOnjQuery):
<script type="text/javascript" src="/_layouts/DependsOnjQuery.js"></script>
<script type="text/javascript" src="/_layouts/jQuery.min.js"></script>
I want MyControl1.js to render before MyControl2.js.
I was able to get this to work by adding a second DelegateControl to the header of my masterpage, and adding jQuery to that delegate. This way, I can make sure that jQuery will always load before everything else, without having to write some logic to delay the loading of my dependant libraries.
<SharePoint:DelegateControl runat="server" ControlId="jQueryDelegate" AllowMultipleControls="true"/>
<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>
It looks to me like the Sequence attribute can be used to control the order in which these guys are rendered. Give your jQuery control a sequence of 50 and your DependsOnjQuery control a sequence of 100 and you should be good.
See the Delegate Control documentation on MSDN for more info.
did you try and set the DEFER="DEFER" attribute on the script.
that would tell the user agent that the script should wait for the page to load and render before it loads the script.
Else you could hack it by setting a variable at the one script, that is set to true when script is loaded. In the other you placed logic that tested (think loop and timeout method) if the script was loaded and then calls your logic when both scripts are loaded.
not very nice, but you need some kind of logic to handle execution, and not just run the methods inline in your script.
To nathan: sequences in delegates are used to determine which of the delegate controls to load. This should have nothing to do with the issue in question. As i understand it the JS files just set the value on a script that just happens to be a delegate control.