I have a Liferay portal custom theme, which is embedding a portlet in the left-side section through some standard Velocity code in portal_normal.vm. When I first embedded the portlet, I set the property portlet-setup-show-borders-default to "false", which caused the portlet to render without the title bar or other "chrome" (which is not what I wanted).
I changed the property value to "true", but what I found is that on the pages where I had already loaded the portlet, it continued to render without the borders and "chrome". If I loaded a different page, however, the portlet then rendered correctly.
How do I force Liferay to re-draw the portlet correctly on those first pages that I had visited? I can't find anything in the Admin GUI (which is what I'd prefer) that might force some cached copy of it to be cleared, and a lot of Google searching hasn't showed anything that works, either. I had found one article that looked like it might work ( http://www.liferay.com/community/forums/-/message_boards/message/772138 ), but the code posted by Artur in the second comment doesn't work for a general portlet, just the Web Content portlet and articles.
Has anyone else run into this and found a solution? Please let me know ASAP!
Thanks in advance
-- Joe --
Finally found the information I needed on Liferay's community forums site, though it required a very specific search term in Google to locate it. Sharing the information here so others will have it more readily (I hope).
When a portlet is embedded in a theme, each page that's loaded for that theme has the VelocityPortletPreferences settings stored in the PortletPreferences table of the database. Even if you change the preference settings inside the template code for your theme, Liferay will ignore the change and use the stored preference values from the DB. The only way to clear out these stored values is to delete the rows in the PortletPreferences table corresponding to your portlet's ID.
delete from PortletPreferences where portletId = '<your-portlet-id-here>'
Once you've done this (no restart of the Liferay service is needed), you can reload the pages that were not displaying properly and they will now pick up the updated preference settings.
Note that the updated preferences will once again be stored in the database after you reload the pages, so if you need to make another change, you'll have to delete the rows for that portlet once again.
Related
we have some sites running Umbraco9, where we have a few templates that are updated by outside developers. We are hooking up to an FTP and downloading their templates (.cshtml), and in backend their editors can choose from these templates to be inserted in a partial.
var setting = JsonConvert.DeserializeObject<CustomTemplateSettings>(Model.Value); // Getting the settings
thetemplate = setting.templateName;// Getting the selected template
showContent = _service.TemplateExists(thetemplate, forcereload);// Checking the selected template exists (physically), possibly downloading it to server
thetemplate = "/Views/CustomViews/" + thetemplate; // creating the path to the template
//Calling template - with some data
<partial name="#thetemplate" model="Model as ContentStructureField" />
Everything is great.... until they want to update their templates. Umbraco has them cached, and I need to either recycle App or hit save on a random Document Type in settings.
I have tried different things, like using #Html.Partial, #Html.CachedPartialAsync, using the tag. I cannot find a way to affect the lifespan or refresh the content of the partial
All googling results in explanations on how to cache specific content. And most Umbraco 9 specific documentation seems to have been lost with the emerging of version 10/11
I need some way to refresh the cache like when saving Document Templates. I do not care about the momentary effect on website performance, as the updates can be planned by the external developers to be non-peak hours.
Thanks in advance
Cannot figure out how to delete the question....
Turned out, that I had constructed the path to the template with a double slash ("/Views/CustomViews//TemplateName.cshtml")
While rendering engine did manage to handle this error and show the content apparently the cache did then not properly subscribe to changes to the file and kept the cached version, requiring a complete flush. Fixing the error in the path made the issue go away.
I want to get programmatically all pages (or one) where portlet is presented on Webspehe portal. Actualy can't find any information about my issue.
The available SPI really was not designed to work back up the chain like this
you can go from layoutcontrol to portletwindow to portletdefinition to portlet
So the ugly way to do this would be to get the content model, loop over all page types, get the layout model for the page, then get the layout controls, from those get the portlet windows, and then go to portlet definition.
The shorter way is to iterate over a full xmlaccess and parse and build the list that way. I did write a whitepaper on how to get the layout controls on the page ftp://public.dhe.ibm.com/software/dw/lotus/Controller_Model_SPI_Final.pdf
I've an existing MVC3 project that implements a certain functionality, this project has it's own views, and a separate Database.
now I'm required to use the same functionality inside one of my orchard project,so I thought that I can host this solution in somewhere and view it inside an iframe or something.
Am I thinking right?,
is this the correct step to take in order to achieve this requirement inside Orchard?
to make it more clear, all I need to do is to view this solution and interact with it's controls and views from a hosting page inside orchard, and the subsequent requests should be handled by my solution in order to hit it's own data store and get back with the requested data in order to be displayed to the user.
any help would be appreciated.
Update:
thanks for Bertrand Le Roy for his answer, I can now view my solution inside my
orchard website.
I came in to one more HUGE problem, which is that my application can no longer connect to my external database.
I've a DB that is hosted in some where else, and I'm using EntityFramework to deal with it.
the problem is that if I put the connection string inside my module web.config, or main orchard web.config, I run into several types of errors like:
"System.Reflection.TargetException: Object does not match target type."
or
"System.Data.MetadataException: Unable to load the specified metadata resource."
My question is: How could I pass my connectionstring correctly to my solution, assuming that I'm using Entity framework as my ORM.
Many thanks.
You will need to put it into a module.
You will have to move route definitions to a Routes.cs file (look at any existing such file for examples).
You will also need, in order to access your data store, to opt out of the ambient Orchard transaction around the data access code (using (var scope = new TransactionScope(TransactionScopeOption.Suppress))).
If you are using dependency injection, you may have some work to move that to the Autofac-based way of doing things in Orchard.
If you want your work to appear seamlessly in the Orchard admin, you may want to decorate your admin controllers with the Admin attribute. If you want your front-end to use the current theme, you'll have to add Themed attributes and maybe refactor your views so that they only emit HTML for the content zone instead of for the whole page.
Add a manifest (module.txt) to your module folder and you should be good to go.
I'm looking for a way to use multiple themes in one XPages application, each theme active in a different section of the application. For instance to support an single .nsf application with both a public facing website (custom theme) and a CMS with a OneUI theme.
You can set which theme is used through the whole application on the XPage Properties tab in Application Properties. It's also possible to change the theme for a user's session with this code:
context.setSessionProperty("xsp.theme", <theme_id>)
But both options set the theme for all pages in the current .nsf, and I'm looking for a way to specify theme X for one part of the application and theme Y for a second part.
Is this possible?
On any page that should use an alternate theme, use the following syntax to apply the property directly to the view root:
<xp:view>
<xp:this.properties>
<xp:parameter name="xsp.theme" value="alternateThemeName" />
</xp:this.properties>
</xp:view>
I tried all of the above, but none of them worked for me. But I found a solution:
Paste this into the view's beforeRenderResponse event:
context.setSessionProperty("xsp.theme", "yourAlternateThemeName")
There is one issue: once you have used this way you have to use it always and on every page as this sets a session property which is stored as long as you are logged in.
Just talked with colleague Tony Mcguckin.
You can change the theme per page. Under all properties of the XPage select data-properties and create a new property with name "xsp.theme" and value "yourThemeName".
While I like the idea of having page-specific themes, based on the specific use case you're describing, the "right" way to do this is to have two separate XPage applications bound to the same back end data store. Not only does this make it simple to specify a different theme for each, it also simplifies the ACL (assuming you'll have different people accessing the public site vs. the CMS), makes it easier to tune performance by having different settings per application, and even without having application-specific settings, should improve performance slightly just because of Java class loader behavior: each NSF acts as a distinct ClassLoader, and each XPage or Custom Control in your NSF results in the storage of a separate class file. So, in theory, if the features of your public site require you to create 5 XPages and the CMS features span 10 XPages, simply splitting these into two separate apps makes it easier for the class loader to retrieve the class for any page a user loads, because it doesn't have to ignore the classes it will never need for that user just to find the one class it does need at the time. So I'm still tempted to find a way to get page-specific themes working just for the "cool" factor of it, but for this specific purpose, I'd recommend using two different applications entirely, with a different theme assigned to each.
I dont know that much about themes but cant you check in your theme (with some ssjs) at which viewroot ( by id? ) you are and according to that include the correct styles , css and other resources?
I need to clear the IIS cache on my server. The exact reason is detailed below; but the reason doesn't matter. I'm 100% sure that this is the solution I need; as detailed below, I have used the process of elimination to determine that this is, indeed, the problem I'm facing, and the solution I need.
I have an MVC3 app that's themeable (skinnable architecture). Think of it as Wordpress; users can develop a theme, download it, and activate it on their site. The theme controls exactly the final HTML output. This is an over-simplification, since I provide an API with useful functions to be consumed by themes.
Anyway, users can change the theme of the site. The theme is currently stored in a static variable. When a view page is rendered, the name of the theme determines the location of the layout file (which contains references to the CSS files, etc.) and the view files. The theme is a setting that persists in the DB.
For example, if I have a theme called "Foo", then when requesting the /Admin page, I might use /Themes/Foo/Admin.cshtml. If I have another theme called "Bar" which does not have that file, then for /Admin it might request /Themes/Bar/Generic.cshtml as the layout.
The problem is that changing a theme means that every single page on the site is outdated. This means that any sites cached on IIS7 will show the old theme; this is incorrect. I need them to show the new theme.
Anyway, IIS7 uses caching by default. I need essentially a way to clear the cache when a user changes the theme. Currently, this is not happening, and users continue to see the old theme until the cache (somehow) expires itself.
I am not using output caching, or any other form of explicit caching; this is a "vanilla" ASP.NET MVC3 application from a caching perspective (i.e. I didn't add/configure any caching). IIS7 has its own default caching. I know this, because if I disable output caching in IIS7 for my Site, I will always see the correct theme after a change.
How can I flush the cache? Other SO questions point to using Cache.blah, and I tried using HttpContext.Current but that is null during tests (using VS test tool) -- because the ASP.NET pipeline is not used in full.
To explain, in an integration test, I basically:
Go to localhost/Test/
Log in (submit values into the forms)
Change the theme by browsing to the right page and clicking the right link
Request another page
See if the theme changed (based on the layout/css file name).
This is all done by code; I use a C# port of HtmlUnit, and along with deploying my app to /Test in IIS, I can essentially browse it like an end user.
Currently, this test passes around 50% of the time. The problem is that IIS is caching the results, and I can't cleanly reliably reset the cache on the server-side.
Again, I'm not talking about clearing the session or the user-side cache; IIS itself is the culprit guilty of caching my application. Nor do I want to completely disable the cache via the IIS settings, a) because I can't force people who install my application to do that, and b) because caching is good.
So how can I force flushing the cache on the server?
For example, I tried programatically touching web.config; this works, but recycles my application pool, and so, kills my static variables; every request means reloading all the static vars from the DB, which kills my performance.
As you requested I have amended this post:
You can use output cache, you say that the selected theme is stored in the database ( like settings for the site ) Well I would add another column with say a GUID and then use this as the varybycustom value.
Your global.asax file will be able to run code:
void Page_Init() {
///code here to get the GUIDforthissitestheme
var outputCacheSettings = new OutputCacheParameters() {
Duration = Int32.MaxValue, //think its maxvalue
VaryByCustom = GUIDforthissitestheme
};
InitOutputCache(outputCacheSettings);
}
At least here you will have output cache, but also every change of theme, changes the GUID so therefore changes the cache and then your page should be new.
I did something like this on a site that listed products, and when the products database was updated the key would be changed, however I can't find what site I implemented it and I work on a hell of a lot of sites.
hope this helps
Set up 'Cache Rule' in 'Output caching' feature with 'File Cache Monitoring' set to 'Using file change notification'. Then 'touch' the files theme change affects, from .net code you could do:
System.IO.File.SetLastWriteTimeUtc(fileName, DateTime.UtcNow);
The issues you are describing sound a lot like a client side caching issue. Have you checked this with a HTTP Proxy like Fiddler to verify if this is getting cached on the client?
If you are seeing HTTP 304's after a template change you may want to try configuring IIS (or your site template) to disable client side caching.
I dont think the approach mentioned for themes is correct.
If we are using STATIC variables , then it will affect all the users and all the pages.(Which is certainly not required.)
We can think of two approaches,
Use theme name in url and make it as a prat if RouteData. So the url "http://myHost/BLUE/.." will return in BLUE theme and "http://myHost/RED/.." will return in RED theme. If user will change theme then url will be updated.
The problem with above approach is next time user browse, it will load default theme.
So better approach will be save theme as a part of user preference. Once user logged in read the theme from DB and set the RouteData value.
Just touch web.config. That's the easiest and most reliable way. Flushing the application pool programmatically is overkill.
If you have a problem finding out where web.config is in a test environment (since System.Web.HttpRequest.Current is null, and similar for Server), you can always use an app.config file to point out the location.
Again, there's no other easy way to do it; even disabling output caching, as mentioned in the question, is hard to do through web.config alone.