Search the FirstSpirit Knowledge Base
Hello,
using the reference implementation of the AdvancedUrlFactory, we are trying to get an URL from the AdvancedUrlFactory with the config parameter "stripWelcomeFileNames" set to true (as it is listed in the documentation).
We are using the parameter together with several others (see code).
Code:
AdvancedUrlFactory advancedUrlFactory = new AdvancedUrlFactory();
Map<String, String> config = Map.of(
"uselowercase","true",
"useregistry","false",
"stripwelcomefilenames","true",
"usewelcomefilenames","true"
);
PathLookup pathLookup = PathLookup.INSTANCE;
advancedUrlFactory.init(config, pathLookup);
String url = advancedUrlFactory.getUrl(pageRef, selfUrlTemplateSet, language, pageParams);
Now the problem is that "stripWelcomeFileNames" gets ignored:
Expected URL:
Actual URL:
/somepath/index.html
We also tried camelCase for the parameter but it's still not working.
What are we missing? How do we fix it?
Thank you in advance.
If you want to simulate what's happening during the generation process, you can use the RenderingAgent. Use the factory method where you can provide template code and use as a parameter a $CMS_REF template snippet. You can look at this code example for inspiration.
This parameter is not used from the class, but it's used in the infrastructure during the generation process when calculating an URL (or more specific: a link). Only the parameters "usewelcomefilenames" and "uselowercase" have an affect when using the class directly.
Okay,
how then can we make use of this parameter/functionality?
If you want to simulate what's happening during the generation process, you can use the RenderingAgent. Use the factory method where you can provide template code and use as a parameter a $CMS_REF template snippet. You can look at this code example for inspiration.