Flow router doesn't rendered template

#1

My router have some trouble. And I don’t know why @@? Cause these routes I created before it’s worked

//Home layout
FlowRouter.route('/', {
	name: 'home',
	action() {
		BlazeLayout.render('main_layout', {top: 'header_bar', main: 'home_layout'});
	}
});

//Login Layout
FlowRouter.route('/login', {
	name: 'login',
	action() {
		BlazeLayout.render('main_layout', {top: 'header_bar', main: 'login_layout'});
	}
});

//Register
FlowRouter.route('/register', {
	name: 'register',
	action() {
		BlazeLayout.render('main_layout', {top: 'header_bar', main: 'register_layout'});
	}
});

//Create Book
FlowRouter.route('/create', {
	name: 'create',
	action() {
		BlazeLayout.render('main_layout', {top: 'header_bar', main: 'create_layout'});
	}
});

//Book's Infomation
FlowRouter.route('/:BookID', {
	name: 'info',
	action() {
		BlazeLayout.render('main_layout', {top: 'header_bar', main: 'info_layout'});
	}
});

//Reading Layout
FlowRouter.route('/:BookID/:ChapID', {
	name: 'reading',
	action() {
		BlazeLayout.render('read_layout');
	}
});

But when I write new create new one, it doesn’t render everything

//Profile Layout
FlowRouter.route('/profile', {
	name: 'profile',
	action() {
		BlazeLayout.render('main_layout', {top: 'header_bar', main: 'info_layout'});
	}
});

//Forgotpassword
FlowRouter.route('/forgotpassword', {
	name: 'forgotpassword',
	action() {
		BlazeLayout.render('main_layout', {top: 'header_bar', main:'forgotpassword_layout'});
	}
});

… Here is the resullt:

it doesn’t render template profile_layout… Here is profile_layout

<template name="profileEdit_layout">
	<div id="container">
		<div class="content">
			<!-- Hồ sơ cá nhân -->
			<div class="c-bg">
				<div class="profile-form">
					<h1 class="taCenter">THÔNG TIN TÀI KHOẢN</h1>
					<!-- Hiện lại thông tin ở trang đăng ký - Bắt buộc -->
					<div class="pro5-row">
						<div class="pro5-col">Tên người dùng:</div>
						<div class="pro5-col">{{PostedBy}}</div>
					</div>
					<div class="pro5-row">
						<div class="pro5-col">Địa chỉ email:</div>
						<div class="pro5-col">email</div>
					</div>
					<div class="pro5-row">
					<div class="pro5-col">Mật khẩu:</div>
					<div class="pro5-col changePass">
						<span id="oldPass" class="oldPass">************</span>
						<input type="checkbox" name="change" id="checkChange" class="checkChange" onclick="changePass()"> Đổi mật khẩu
						<div id="change" class="change">
							<input type="password" name="password" id="password" placeholder="Mật khẩu cũ" required><br>
							<input type="password" name="password1" id="password1" placeholder="Mật khẩu mới" required><br>
							<input type="password" name="password2" id="password2" placeholder="Nhập lại mật khẩu" required>
						</div>

					</div>
				</div>

					<!-- Thông tin thêm - Không bắt buộc -->
					<div class="pro5-row">
						<div class="pro5-col">Giới tính:</div>
						<div class="pro5-col">
							<input type="radio" name="gender" value="male" checked> Nam 
						  <input type="radio" name="gender" value="female"> Nữ 
						</div>
					</div>
					<div class="pro5-row">
						<div class="pro5-col">Số điện thoại:</div>
						<div class="pro5-col">
							<input type="text" name="" id="" class="form-control" value="0123456789">
						</div>
					</div>
					<div class="pro5-row">
						<div class="pro5-col">Trang web liên kết:</div>
						<div class="pro5-col">
							<input type="text" name="" id="" class="form-control" value="123.org">
						</div>
					</div>
					<div class="pro5-row">
						<div class="pro5-col">Giới thiệu bản thân:</div>
						<div class="pro5-col">
							<textarea></textarea>
						</div>
					</div>

					<!-- Chuyển về trang profile với thông tin đã cập nhật -->
					<div class="bt-pf-edit"><a href="/{{username}}">Cập nhật hồ sơ</a></div>
				</div>
			</div>
		</div>
	</div>
</template>

#2

My guess is that because you have

FlowRouter.route('/:BookID', ...
FlowRouter.route('/:BookID/:ChapID', ...

It is taking /profile in your url to mean a :bookID instead of matching /profile.

The trouble is that You’ve made your routes ambiguous by making the first part of the path both static and dynamic.

Try changing the two dynamic ones to sit behind another static like so:

FlowRouter.route('/book/:BookID', ...
FlowRouter.route('/book/:BookID/:ChapID', ...
2 Likes
#3

It’s working thank you :">