country is getting appended twice in storefront URL(spartacus) - spartacus-storefront

I'm having trouble with the basesite service. We currently have three websites: global, cn (China), and tw (Taiwan) (Taiwan)
To pick the region, we have a drop-down menu on the global site. Using baseservice(spartacus), the selected region is set.
this.baseSiteService.setActive(region);
localhost:4200/cn/cn When the above line has run, appears in the URL
Could someone please explain how it is appended twice in the url and how to override this?

You said in the comment that you "don't have any services or configs related to site context". So I guess what you see in the URL by default are 2 different site contexts: baseSite and language, which "by coincidence" have the same values pairwise):
localhost:4200/<baseSite>/<language>
I guess what you want to achieve in this case is to have an URL of the shape localhost:4200/<baseSite>. This can be achieved in 2 ways, depending on whether you're using static or automatic site-context configuration.
You can configure which site contexts should appear in the URL in 2 ways:
if you're using CMS-driven site context configuration in Spartacus (aka. automatic site-context-configuration), then you need to configure it in CMS Backoffice tool. As in the screenshot below, for each of your basesites go to WCMS -> Website -> <select your base site> -> Administration (tab) -> URL Encoding Attributes and put there only the value storefront (get rid of language or anything else there). And save the changes.
if you're using static site-context configuration in Spartacus, then you need to provide the following static config in your app:
provideConfig({
urlParameters: ['baseSite']
})
References:
Automatic Site Configuration Detection from URL (demo video)
Spartacus docs on Site-context configuration

Related

Spartacus: Wrong currency code in cart API parameters

We have implemented multisite configuration recently, but facing an issue after it.
When we have it configured (in both mode - Static/Dynamic configuration), we are getting error in cart API when refreshing the page. After analyzing it we found that it is happening due to wrong site context parameter(currency code) and it is happening only in case of non SSR build, when we use SSR it works fine. In case of normal build, it is adding “USD” as currency code in API call with dynamic site binding and if we are using static binding then it is picking the first currency code even if we are on secondary website. Spartacus framework is picking it from default list of currency codes when hitting cart API on page refresh.
Spartacus version:2.0
Screenshot
Error message
Please share a solution on this.
You can add currency in static configuration (e.g. adding currency: ['JPY'], inside context, currency will be JPY).
If your multiple sites using different "currency" (e.g. one site uses "USD" and the other one uses "JPY"), then you cannot use static configuration. Dynamic configuration loads all base sites data, and get the default currency from each site (the value is: the defaultCurrency of the first store in the site). So, you need make sure the site data is set correctly in backend.

Smart edit unable edit the page emailsignmodal

Hi Hybris 1811 smartedit I am trying to edit Email Signup Modal but as soon as I click on the link it redirects me to below page. I have multiple sites so sometimes I am getting this warning: WARN [hybrisHTTP20] [DefaultCMSSiteService] More than one site associated with URL [https://localhost:9002/?site=XXXX]. Returning first. Did anybody faced similar issue?
The main problem is that you have more than one site containing the same urlPatterns
This attribute represents a regex that is used by CMSSiteFilter to decide the website that will be used based on the URL introduced in the browser or requested by smartEdit(i.e https://localhost:9002/?site=XXXX)
In this case, more than one instances of CMSSiteModel were found and the first one was used.
In order to fix this you need to adjust each site to have its own, unique urlPattern . If you have apparel and electronics sites, the regexes for both should look like this
apparel --> (?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=apparel)(|\&.*)$
electronics --> (?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=electronics)(|\&.*)$
This can be changed in backoffice for each and every site:
Make sure that the preview URL is also changed accordingly so that SmartEdit will know how to perform the HTTP requests for this site:

Get Current Page Url In Adobe CQ5 for Canonical Link

Is there a standard way in Adobe CQ5 to get the current page url in order to create automatic canonical links in the head of the JSP?
Basically we have a dialogue config box where you can override the canonical link, but by default if this is empty I want to construct the link based on the raw URL path for the current request.
The JSP for the head is shared across all requests.
Many thanks
The ${currentPage.path} variable will give you the path of the parent page to the current resource, but you should use the Externalizer to make this into a nice user-facing URL, (i.e. applying any mapping rules that you have in place & using the correct domain name, rather than the server name e.g. prod-server-123)
i.e.
ResourceResolver resourceResolver = request.getResourceResolver();
Externalizer externalizer = resourceResolver.adaptTo(Externalizer.class);
String canonicalUrl = externalizer.publishLink(resourceResolver, "http", currentPage.getPath());
You can customise what the externalizer treats as the base URL via Felix, or via an osgi:Config node in your repository. and read more on the official docs on the Adobe site.
(Note that the Externalizer is CQ5.5+)

Dynamic landing page in Alfresco Share

I'm trying to figure out how to implement a mechanism that decides dynamically what's the landing page for a user.
I know that the default landing page is relatively easy to customize, as you can see in the following link:
http://blogs.alfresco.com/wp/ddraper/2011/11/01/advanced-share-customization-part-1/
http://zscribble.wordpress.com/2012/02/13/how-to-change-user-landing-page-in-alfresco-share/
But it is not enough because I need go a little further; after the successful authentication of any user, I need to retrieve the site/s that a user belongs to and then redirect to the dashboard of any of the sites.
I guess there is any authentication service that redirects to TOMCAT/webapps/share/site-index.jsp, and from here to either the user dashboard or a site dashboard, depending on the parameters received. If I'm right with my assumption, I understand I just should customize such supposed authentication service in order to get the user's sites and then redirect to the appropriate site dashboard's URL.
Am I in the right way? If not, any idea on how to proceed?
Thanks.
There are two possible approach in order to implement a mechanism which dynamically redirects to a page after a successful authentication in Alfresco Share.
The easiest way consists in the next steps:
Change the default landing page by updating the value of the tag <root-page> in the file alfresco\site-data\configurations\slingshot.site.configuration.xml (the default value is site-index).
Create a custom Surf page according to the value defined before.
Create a custom template-instance
Create a custom FreeMarker template, exclusively containing a region that loads a webscript (will be created in the next step).
Implement a webscript that decides whatever a URL to redirect to (in my case I have to retrieve the user's sites via RESTful API and then redirect to a site's dashboard)
Perform the redirection similarly to the accept-invite component is doing
The other possible way is to override the classes PageView and PageViewResolver, this way you can perform the redirection to the landing page in a single step rather than two steps, what is more efficient as a consequence. I didn't developed this solution so I cannot give more details but according to what an Alfresco Engineer says, it is viable to achieve.
If you want to know more about this, read this thread.

Passing the referrer to omniture in server-side code

I'm trying to implement some omniture requests on server-side. I've got the calls set up, and the requests make it to omniture, but the referrer is not showing up in omniture.
Here is an example of one of the urls for omniture my code creates. Am I missing something?
http://[id].112.2o7.net/b/ss/[group]/1/H23.2/s1328206514850?AQB=1&ndh=1&ns=[id]&g=http%3A%2F%2F[domain]%2Flogin.asp&vid=1328206514850&pageName=Login%20Page%20!test!&r=http%3A%2F%2Ftest.com
The Internal URL Filters in the Report Suite Admin Console specifies what your internal domains are (i.e your domains). Any referal from any other domain will be recognised as a referrer.
I generally use a Firefox addon like WATS to debug the variables that are on a particular page, including referrer.
Keep in mind that there needs to be a referral from an external site. If you just type in the URL, or reload, or click from your own site, there is no referral. When testing this, I would create a page on another domain (e.g. localhost), and create a link to my page.
https://omniture-help.custhelp.com/app/answers/detail/a_id/1652/kw/JavaScript/related/1
COMPARISON: s.linkInternalFilters vs. Internal URL Filters
s.linkInternalFilters: The linkInternalFilters variable within the s_code.js file is used in exit link tracking. If s.trackExternalLinks is set to true, it is used to determine if a specific link a visitor clicked on is internal to your organization's site or not. Clicked links that match a value in s.linkInternalFilters are ignored, while links that do not match any values are sent to SiteCatalyst as an exit link.
Internal URL Filters: The Internal URL filters within the Admin Console is used in Traffic Sources reports, such as the Referring Domain report. Every s.t() request checks to see if the referring URL (contained within the referrer variable) matches any of the rules set up. Referring URLs that match any of these rules are excluded from all Traffic Sources reports, while referring URLs that do not are included.
It is recommended that s.linkInternalFilters and Internal URL filters match eachother, however the two operate completely independently and serve completely different functions.
The last part of that image is the referrer value, r= . Is that the correct value? Also you should check your Internal URL Filters in the admin console for that report suite. Typically for new report suites you will find the value of . (a single period) set in there. If you do have that then no referrers will be recorded.