Is there a way to disable the home page or make pl...
# suitecommerce
m
Is there a way to disable the home page or make plp as the default view when one opens the website? Like in wordpress we can make the posts page as the main page, anything like that would be really helpful.
s
I would imagine setting up a 301 for "/" would do the trick
m
But the internal backbone home touchpoints can't be handled via NetSuite redirects.
s
I'm struggling to understand what it is you want to achieve here
m
We have a scenario where main website is on asp/php and using SuiteCommerce for shopping experience. So we don't want to use SC default home page.
<script>
// Backbone route events
Backbone.history.on('route', function(router, route, params) {
router.execute = function(callback, args, name) {
var homeFragments = ['', 'cart?whence='];
var fragment = Backbone.history.getFragment();
if (_.contains(homeFragments, fragment)) {
redirectToHome();
} else if (callback) {
callback.apply(null, args);
}
}
});
// Home touchpoint navigation
$('div.main').on('click', '[data-touchpoint="home"]', function() {
var homeHrefs = ['/', Backbone.history.location.origin + '/'];
var href = $(this).prop('href');
if (_.contains(homeHrefs, href)) {
redirectToHome();
return false;
}
});
// External url redirect
function redirectToHome(url) {
url = url || '<http://external.url.com/>';
Backbone.history.location.href = url;
}
</script>
s
That is rather unpleasant code
m
i have managed to handle most of the SPA redirects but stuck at two points: • On the cart page
/cart
or
/cart?whence=
in the url don't trigger router event • Browser back button still redirects on the home page initially
We don't want to do any sort of customization so the only possible way is to handle at theme level
s
I don't think there is a straight-forward way of achieving what it is you want. Two less but still unpleasant ways come to mind: 1. Add an event listener to the application object that,
beforeAppendView
, you check the URL and if it's the homepage, trigger a redirect to your desired page 2. Changing the home.tpl to contain script tag that calls the internal redirect
m
1. Can we access beforeAppendView at theme or cms level? 2. Placing a redirect there will still be a router nav to home.tpl and then followed by script tp some external url. Still not mitigating what we are looking for.
s
Honestly, I'd just change home.tpl to this
<div class="home"><script>Backbone.history.navigate('/search', {trigger: true})</script></div>
but I hate it so much
It's probably the best elegant way to handle it
m
Seems like a good quick fix. But will it also display home first then the search page?
s
It won't show anything on the homepage
You're removing the entire page's content
And replacing it with an internal redirect
m
Seems to be a great idea! Thanks @Steve Goldberg šŸ‘
s
It's not great at all. But it's probably the least worst way of doing it šŸ™ƒ
m
I know but can't do any sort of customization in this phase else I would have handled it the other way around.
We added a redirect msg on home page and used this code in home.tpl for redirection
location.replace('bla bla');
s
Why?
m
Because we need to redirect to external website home page not NetSuite one
s
This is a rollercoaster
m
Yeah we finally settled down on this approach šŸ™‚
šŸ‘šŸ» 1