The Issue
We have two sites, one domain, we want to setup a virtual directory on the domain which can access the second site.
IIS virtual directory doesn't seem to do the trick, sitecore does not seem to play nicely.
Is there a potential work around using sitecore?
The Environment
We have the following folder structure for two of our sites:
C:\Sitecore\Site1
C:\Sitecore\Site2
Site 1 and Site 2 both connect to the same web, core and master databases.
To access the cms for both sites in the browser we do:
www.mysite1.com/sitecore
From Site 1's cms we create content, layouts and templates for Site 1 and Site 2.
The Solution
What we did is in the first sites web.config we defined the site as normal:
<site name="site1" hostName="mysite1.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/MyItem1/" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
In the second sites web.config we defined the site slightly differently:
<site name="site2" hostName="mysite1.com" virtualFolder="/Site2" physicalFolder="/" rootPath="/sitecore/content" startItem="/MyItem2/" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
The second site we defined a virtual folder which you can notice above that was the only difference along with the obvious start item differences.
Site 1 will respond like normal. You can visit mysite1.com it will load the start item relevant for website 1.
When you visist mysite1.com/Site2/ it will load the virtual folder defined in the second site and load its relevant start item.
That is pretty much it works like a charm.
And finally #Mark Ursino thanks for your help.
To Note
You need have sitecore scalability configs enabled for any of the above to work
From what I think I understand, I think you need to make some changes in the config to set the "sub-folder site" as a virtualFolder:
<site virtualFolder="/subsite" physicalFolder="/subsite" rootPath="/sitecore/content" startItem="/MyItem/" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
Note that virtualFolder="/subsite" and physicalFolder="/subsite" point to the subfolder, but I don't think you need that physical folder really there.
Reference used.
Maybe this post will be useful http://sitecoreblog.alexshyba.com/2012/02/have-sitecorecontent-in-your-link-time.html
Related
I have tried looking into using Strongly Typed models (setting Umbraco.ModelsBuilder.ModelsMode to either AppData or Dll) for a while now, and I never fully understood how it works.
I already changed the Umbraco.ModelsBuilder.ModelsMode value and I generated the models inside the backoffice ModelsBuilder, then I included the App_Data\Models into Visual Studio, but what then?
#inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Home>
#using Our.Umbraco.Vorto.Models;
#using Our.Umbraco.Vorto.Extensions;
#using ContentModels = Umbraco.Web.PublishedContentModels;
This is the code for my Home view. No matter what I try, I cannot access the #Model.PROPERTY or #CurrentPage.PROPERTY from my content. I can see the different properties inside my MODEL.generated.cs files.
What steps do I need to take, in order to do things like #Model.PROPERTY?
Okay, so it seems like there has been some changes in the newest 7.6.9 release (or maybe 7.6.8). This is what I had to do now:
<add key="Umbraco.ModelsBuilder.Enable" value="true" />
<add key="Umbraco.ModelsBuilder.ModelsMode" value="Dll" />
Then I can go into the backoffice and generate the models. The models are included into the project (location: ~\App_Data\Models\). Umbraco.Web.PublishedContentModels.dll from the ~\bin\ folder has to be included as well.
Then, because of .NET Core I think, I got an error when I tried loading my application saying this:
More than one type want to be a modle for content type File
This was caused because I had included everything inside ~\bin\, which means I had also included my Project.dll, Project.dll.config, and Project.pdb files. The Project.dll file also includes the same models, apparently, so I had to exclude those 3 files.
Now it simply works and I can now do #Model.Content.PROPERTY flawlessly.
You're not talking about "Dynamic" models, but Strongly Typed Models generated by Models Builder. By default Umbraco ships with PureLive setting which is keeping models in memory and generates them on the fly. It can be considered as "dynamic".
The tool and it's behaviour is well documented here: https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki
Regarding modes of it, you can find all about it exactly in this place: https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/Builder-Modes
But answering your question - after you've changed the configuration, you need to compile your application as you need to keep those classes inside the DLL with which you're shipping your website. You're also able to regenerate models straight from your Developer's dashboard in Umbraco Backoffice.
You need to remember that if you would like to use DLL, LiveDLL or PureLive configuration - you need to get rid of classes generated inside your AppData or any other directory used with this mode as you'll experience errors saying about 'More that one type want to be a model for content type File'.
After that you should be able to access all properties of the document type via Model.Content.PropertyAlias. You probably missed the Content object, which is the strongly typed, IPublishedContent representation of you document.
Hope it will help you to make it work :)
Im building a very custom CMS on top of Symfony CMF Components/Bundles. I read almost everything i could about the CMF Components/Bundles and i have the "architecture" kinda defined. Im experienced/familiarized with Symfony2 components.
The CMS should provide a way to manage multiple sites.
A Site contains Pages.
A Page, requires a title and may have content. A page can also have blocks associated(Those already provided by the Block Bundle, and others with custom functionality developed by me for the CMS).
For now i defined two Documents(Site and Page).
Based on the application requirements im using the CoreBundle, BlockBundle, RoutingBundle, DoctrinePHPCRBundle, and DoctrinePHPCRAdminBundle.
Based on this requirements the expected Repository Tree should be something like:
/sites
/site1 ( nodename of the Site Document )
/pages ( all pages of this site )
/page1 ( nodename of a Page Document )
/page2
/routes ( all routes of this site )
/site2
/pages
...
The configurations for CoreBundle:
cmf_core:
persistence:
phpcr:
basepath: /sites
enabled: true
Because i need nodes(/pages, /routes) for each site, how can i initialize them? My first idea was onPostPersist event of a Site document i initialize the required nodes.
use PHPCR\Util\NodeHelper;
...
public function initSiteNodes(ManagerRegistry $registry, Site $site)
{
$session = $registry->getConnection();
NodeHelper::createPath($session, $site->getId()./pages);
NodeHelper::createPath($session, $site->getId()./routes);
$session->save();
}
So my questions are:
Is this architecture feasible and is SonataAdminBundle prepared for such a structure?
Great to hear you are building a custom CMS on top of the CMF. This is one of the main intended use cases for it.
For your usecase, one important thing to note is that the route base paths can be an array of paths. If you know the sites that will exist, you can simply configure base paths for all of them.
If they can be dynamically created, you will need some more work. You could check if the expression language can help you, or write a symfony request listener that comes very early and sets the right base path on the cmf_routing.phpcr_candidates_prefix service.
The sonata phpcr-odm admin was not really optimized for multisite use cases. However, with the help of the permission system, you should be able to control who may see what.
You could also write to the symfony-cmf-users mailing list. A couple of people did multisite projects with the CMF and might have additional ideas or inputs. And feel free to open pull requests or issues on the corresponding CMF repositories if you see things that could be improved.
my site uses JSF and the url appears to be, http://mysitename.com/wompower6/faces/home.xhtml
I am using prettyfaces, so if I use the following in pretty-config.xml, i can change the name to http://mysitename.com/wompower6/home
<url-mapping id="home">
<pattern value="/home" />
<view-id value="/faces/home.xhtml" />
</url-mapping>
my questions are
how can i remove the application
name wompower6 , so that the url
becomes mysitename.com/home ?
in my web.xml, i have
<welcome-file>home.xhtml</welcome-file>,
but this does not seem to work. When
i type, mysitename.com, it does not
get mapped to home.xhtml. any clue
here?
how can i remove the application name wompower6 , so that the url becomes mysitename.com/home?
This is a webapp <Context> setting and configuration is dependent on the servletcontainer used. If you're for example using Tomcat, then there are basically 2 options to make your webapp the root webapp.
Rename the WAR file to ROOT.war and Tomcat will by default deploy it on context root.
Set path attribute of <Context> element in Webapp/META-INF/context.xml (or Tomcat/conf/server.xml, depending where you'd like to define it) to an empty String. E.g.
<Context path="" ...>
Other containers support similar constructs. Consult their documentation for detail. If you're using an IDE like Eclipse, then you can also set it in the Web Project Settings property of the project properties (rightclick project and choose Properties). Set the Context root value to just /.
in my web.xml, i have home.xhtml, but this does not seem to work. When i type, mysitename.com, it does not get mapped to home.xhtml. any clue here?
I assume that you're talking about the <welcome-file> setting. This has to point to a physically existing file, not to a virtual URL, such as /faces/*. There are basically two ways to overcome this:
Provide a physically existing /faces/home.xhtml file (it can even be left empty).
Replace the ugly /faces/* URL pattern of the FacesServlet mapping in web.xml by *.xhtml so that it will just kick in on every request for a XHTML file.
<url-pattern>*.xhtml</url-pattern>
This way you don't need to fiddle with /faces/* URL patterns.
I have an MVC3 app that's using NHibernate. All was going well until I started to try and add second level caching. After browsing the web for a few hours I finally found what I think is the right dll (NHibernate.Caches.SysCache2.dll) and have added it to my project.
However, I can't find any help for configuring it with an MVC app. All the examples refer to having an App.config file (I presume this is for Web Forms). I'm a Java developer who's learning .Net so I'm not so familiar with how to rig everything up.
Could someone point me in the right direction. I'm using xml hibernate (hbm) files.
Thanks.
I'm using 2nd level caching with MVC3 and NHibernate.Caches.SysCache.dll like this...
1st, add a config section to your web.config file like this
<configSections>
<section name="syscache" type="NHibernate.Caches.SysCache.SysCacheSectionHandler, NHibernate.Caches.SysCache, Version=3.0.0.4000, Culture=neutral, PublicKeyToken=6876f2ea66c9f443"/>
</configSections>
add a syscache section to your web.config under your configuration section like this:
<syscache>
<cache region="SomeCustomNameRegion" expiration="86400" priority="5" />
</syscache>
in my hibernate.cfg.xml file i have the following properties added:
<property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.use_second_level_cache">true</property>
I'm using FluentNhibernate to create my mappings and add this to support caching:
public CustomerClassMap()
{
Cache.NonStrictReadWrite();
Id(x => x.Id);
Map(x => x.Name);
//... more properties
}
And then in my data access code, I have something similar to this for queries that I want cached:
public IEnumerable<Customer> GetAllCached()
{
return Session.CreateCriteria(typeof(Customer))
.SetCacheable(true)
.SetCacheRegion("SomeCustomNameRegion")
.SetCacheMode(CacheMode.Normal)
.AddOrder(Order.Desc("CreateDate"))
.List<Customer>();
}
Here are some helpful links to get into a little more detail. There's nothing specific about MVC3 that you need to worry about, and most is unchanged from earlier versions of NHibernate as far as i can tell.
http://www.klopfenstein.net/lorenz.aspx/using-syscache-as-secondary-cache-in-nhibernate
http://blog.symbiotic-development.com/2008/02/27/more-configuring-nhibernate-caches/
I have two seperate clean installations of Umbraco 4.5.x and both are having similar problems with page handling. If I browse pages by ID like /1083.aspx the page displays correctly, but if I try to browse by name like /about-us.aspx it gives 404 - file or directory not found.
Thanks in advance.
Sanjay
Sanjay,
This is because when you're hunting for root content nodes, the umbracoHideTopLevelNodeFromPath appSetting in the web.config is set to true by default.
As the name might imply, this hides the top-level node from the URL path. You can set it to "false" to override this behaviour.
HTH,
Benjamin