Jayson
February 24, 2016, 5:01am
1
Hi All,
I’m trying to display a simple landing/home page and then link to other pages, e.g. FAQ, About Us, etc. using FlowRouter as well as the helpers package but I keep getting a blank page. Please assist
client/lib/routes.js:
FlowRouter.route('/', {
name: 'Landing',
action() {
BlazeLayout.render('LandingLayout');
}
});
FlowRouter.route('/faq', {
name: 'faq',
action() {
BlazeLayout.render('MainLayout', {main: 'FAQ'});
}
});
client/layouts/LandingLayout.html:
<template name="Landing">
<body>
<header>
</header>
<main>
Usual code found on landing pages, including - <p><a href="{{path For '/faq/'}}">FAQ</a></p>
</main>
</body>
</template>
client/layouts/MainLayouts.html:
<template name="MainLayout">
<header>
</header>
<main>
{{> Template.dynamic template=main}}
</main>
</template>
client/faq.html:
<template name="FAQ">
<head>
<title> </title>
</head>
<body>
"Some Content"
</body>
</template>
sacha
February 24, 2016, 5:24am
2
You can use triple backticks to format your code. Or else link to a GitHub gist.
So I’m thinking your BlazeLayout.render('LandingLayout')
should be BlazeLayout.render('Landing')
, which matches your template name.
Jayson
February 24, 2016, 6:47am
4
Code has been corrected to display properly now. Please comment as to weather my pathFor is correct as well
Check out this package of helpers for flow router . Things like pathFor aren’t built into flow router by default.
goatic
February 24, 2016, 7:01pm
6
It might also be fun to built the helper yourself?
just off the top of my head you could probably do something like this…
Template.registerHelper('routePath', name => name ? FlowRouter._routesMap[name] ? FlowRouter._routesMap[name].path : undefined : undefined)
Jayson
February 25, 2016, 3:22am
7
Thank you @vigorwebsolutions , that didn’t seem to be the issue though. Should the file name also be the same as the template name perhaps?
Maybe I should just try ReactRouter
Jayson
February 25, 2016, 3:23am
8
Yeah, that’s the package that I loaded. Can’t check if the pathFor works though since the landing page isn’t even loading
No, the file name can be whatever you want. You could have all of your templates in one file, if that was your prerogative.
Are you using the kadirahq:blaze-layout package?
You could certainly switch to another router, but I think the consensus is that FlowRouter is an easy, straightforward router to use.
Jayson
February 26, 2016, 2:55am
10
Thanks guys, it’s miraculously working now. Must have needed a system reboot or something