Hybris language not being encoded in URL - sap-commerce-cloud

I have created my custom storefront b2c electronics and I found out that the LANG is not being persisted in the URL while I navigate through the page.
This is my local.properties site url config:
hac.webroot=/hac
customstorefront.webroot=
customstorefront.webroot=/custom
storefrontContextRoot=
website.custom.http=http\://custom.local\:9001/
website.custom.https=https\://custom.local\:9002/
This are my url patterns:
(?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=custom)(|\&.*)$
(?i)^https?://custom\.[^/]+(|/.*|\?.*)$
(?i)^https?://api\.hybrisdev\.com(:[\d]+)?/rest/.*$
(?i)^https?://localhost(:[\d]+)?/rest/.*$
Am I missing something?

To have the language as part of the Url, you also need to specify that this parameter is part of the UrlEncodingAttributes on your site. You can do this through an impex, or change it through backoffice
For example, something like this
INSERT_UPDATE CMSSite; uid[unique = true]; urlPatterns ; urlEncodingAttributes
; $siteUid ; (?i)^https?://custom\.[^/]+(|/.*|\?.*)$ ; language
If you also want the storefront to be part of the url, you also need to append it in this property like storefront,language.
Do note that the order in which you place the attributes also determines the order in which they appear in the url

Related

Kentico custom page url with URL "Path or Pattern" feature

Updated: As I put in the comment under Brenden's response. I think the issue is not related to multilingual site, but it's with using Properties/ URLs / Path or Pattern feature. After adding value to the field Path of Pattern, the whole navigation stops working properly.
I have a multilingual site (English, French). Currently the URLs are like below:
English: www.domain.com/en-us/contact-us
French: www.domain.com/fr-fr/contact-us
What I want for French is a custom (translated) url www.domain.com/fr-fr/contactez-nous
I followed this Kentico instruction - the bottom part of the page with using Path or Pattern by adding /contactez-nous in the box. Things seem ok, but upon clicking on the page with the new URL on the French site, the whole main navigation (done with Hierarchical Viewer) seems to stuck with that URL; clicking anywhere on the nav doesn't do anything.
Links outside the nav works fine. How to make the nav work again. Thanks for your help!
I think I got it. The GetDocumentURL() is using NodeAliasPath to determine the URL. However, if you have not specified the NodeAliasPath column in the Columns property of the hierarchical viewer, then the current page's NodeAliasPath is used - and thus all items have the same URL. Adding the NodeAliasPath to the Columns property should fix the issue, so the hierarchical viewer has access to the data of each individual item.
EDIT: it looks like that in some cases the DocumentURLPath column must be specified too.
Make sure you're testing this in another browser or even another browser in a private window. If you are testing in a new tab in the same window, the CMS caches the selected language in the Kentico UI and shows that in the browser window.
For instance, if you have selected "French" on the pages app in the bottom left under the content tree, then navigate to your site in a new tab, it will display French no matter how many times you change the language selector on your public site to a new language.
Secondly, check the URL aliases for the given pages in each language. Make sure you don't have an alias that is the same in each language. For instance /contact-us with French and /contact-us in English.

Call a string value to create a meta tag?

I need to create meta tags for the seo of my website.
I am using WHMCS and a custom template
Any page is compiled through the header.tpl, footer.php page1.tpl and page1.php pages
What I tried was to add
">
to header.tpl which does add the line of code to the "output source"
and I added
$pgDesc = 'Any custom description';
to the page1.php
Somehow the echo $pgDesc does not call the value correct
Any ideas ?
Just add your metatags to header.tpl. And that's all. You can get your title/desctiption/keywords strings from various sources: whmcs variables, translation strings, and even some db.
See http://docs.whmcs.com/Seo

Joomla - Custom component url rewrite

I have the following component #
?option=com_tmportal&module=user&task=main
I've enabled url rewriting and setup the htaccess file which is all working correctly, how would I create a rewrite rule that allows me to access the component above by simply doing:
/portal/ = ?option=com_tmportal
or
/portal/user = ?option=com_tmportal&module=user
or
/portal/user/main = ?option=com_tmportal&module=user&task=main
Thanks for any help, much appreciated :)
You haven't specified Joomla version so I'm assuming 1.6/7/2.5 in my answer.
Short Answer: If you're using Joomla!'s default .htaccess then all you have to do is create a Joomla! menu to each of your components views with the right alias eg. portal for your default component access ie. ?option=com_tmportal.
This is what the default .htaccess does it passes all of the elements after the base URL to index.php to help select the component and view.
Longer Answer
When you create a component for Joomla! you specify the menu settings for each view using an XML file usual the same name as the view file in it's view/tmpl/ directory.
Typically the url to a specific view & task in a component would look like these:
?option=com_mycomponent
?option=com_mycomponent&view=userdetails
?option=com_mycomponent&view=userdetails&task=main
Joomla!'s framework will automatically use the view & task params to get your components correct controller and view (or sub-view). I'm not sure that it does anything with the module param that you have in your URL's so I'd guess you're trapping and processing that yourself.

Problem with custom registration fields in an multistore setup in magento

I have 2 sites running on my magento platform.
For site2, I added new fields to the registration page and it works properly.
Now, I noticed that when I try to register in site1, on submit I am shown a validation message that the additional fields I have added for site2 are required.
How do I make sure that the additional fields added for site2, are asked only for site2 and not site1?
I have separate themes for both site1 and site2 and both of them have separate register.phtml files.
In the config.xml file for adding custom registration fields, I have this added:
<customer_account>
<employee_id>
<create>1</create>
<update>1</update>
</employee_id>
<doj>
<create>1</create>
<update>1</update>
</doj>
<mobile_number>
<create>1</create>
<update>1</update>
</mobile_number>
<alternate_mail>
<create>1</create>
<update>1</update>
</alternate_mail>
</customer_account>
which is under <global> tag. I assume Magento is reading this. How do I make sure magento reads this config file for a particular site/store? Thanks.
If you want to see the entire XML tree magento has compiled from all XML configuration files:
header("Content-Type: text/xml");
die(Mage::app()->getConfig()->getNode()->asXML());
Will present you with a single compiled XML of their entire tree, this may help in determining if your changes are being added.
Also be sure and checkout Alan Storms CommerceBug as it has this functionality built-in.
How I solved a similar situation is that I added system configuration options to allow me to set which custom field is enabled all the way down to the store view scope. This means I don't need to have separate phtml for the different stores, but can just use the same.
I've also created custom phtml 'widgets' - modelled on the Magento DOB, Gender and Name widgets. The custom widget block code has a 'isEnabled()' method that checks the config flag. In, say, my checkout/onepage/billing.phtml I can say:
<?php $_mywidget = $this->getLayout()->createBlock('mycompany/customer_widget_mywidget') ?>
<?php if ($_mywidget->isEnabled()): ?>
....
<?php endif ?>
Hope this helps.

Construct the url to fetch a page by url

With this code I create a page in a Google site:
pageEntry = new WebPageEntry();
pageEntry.setTitle(new PlainTextConstruct(PageTitle));
..
..
client.insert(new URL(getContentFeedUrl()), pageEntry);
If the PageTitle contains something like "création" the page will created with the name https://sites.google.com/.../.../cration. So "création" is changed to "cration".
Is the process to change the page name available in the API? I would like to fetch the page by its path, but the only key I have is "création".
Maybe a better solution would be to strip the diacritics from the characters in the string before setting it as a page title? For instance, see the javascript function here. Then you page would be created with the URL /creation, which could be more desireable.

Resources