The django-cms always uses the top-most page as the start/landing page. I now want to have a navigation that looks like this foo-home-bar and home to be the landing page.
django-cms始终使用最顶层的页面作为开始/登陆页面。我现在想要一个看起来像这个foo-home-bar的导航和home作为登陆页面。
One way would be to add a dummy page at / that redirects to /home, but this seems a bit crude to me. Is there any better solution? I don't mind changing the code of the cms itself.
一种方法是在/重定向到/ home添加一个虚拟页面,但这对我来说似乎有点粗糙。有没有更好的解决方案?我不介意改变cms本身的代码。
3 个解决方案
#1
3
The easiest way, instead of creating a page that redirect is to just use django's redirect generic view.
最简单的方法,而不是创建一个重定向页面只是使用django的重定向通用视图。
set it in your top level urls.py
将它设置在您的*urls.py中
url(r'^$', RedirectView.as_view(url='/home/')),
and of course add the from django.views.generic.base import RedirectView
import at the beginning and you should be all set.
当然,在开头添加django.views.generic.base导入RedirectView导入,你应该全部设置。
('^$'
only catches the root url and the RedirectView redirect wherever you want. I was a bit unsure about using it myself, but I saw a lot of major websites doing a redirect when you get on to their site...)
('^ $'只捕获根网址和RedirectView重定向,无论你想要什么。我有点不确定自己使用它,但我看到很多主要网站在你进入他们的网站时进行重定向......)
#2
1
The first page you make seems to be the home page, simply add other root pages as needed and enable navigation on them. This is what i have done.
您创建的第一个页面似乎是主页,只需根据需要添加其他根页面并启用它们的导航。这就是我所做的。
Our first page was test, and then some child pages. in the admin page you can click and drag the pages around to change the child/parent order. we renames test to home and shifted the child pages to another root page.
我们的第一页是测试,然后是一些子页面。在管理页面中,您可以单击并拖动页面以更改子/父订单。我们将test重命名为home并将子页面移动到另一个根页面。
You can also override the default menu by make a template in menu/menu.html In there you could override the order by adding in some if statements. You could also hardcode it in your base.html having the menu something like: <ul id=menu> <li><a href="/foo/>foo></a></li> <li><a href="/">Home</a></li> {% show_menu %} <ul>
您还可以通过在menu / menu.html中创建模板来覆盖默认菜单。在那里,您可以通过添加一些if语句来覆盖订单。您也可以在base.html中对其进行硬编码,其菜单类似于:
And just have bar and the other pages you wanted in the navigation but not foo or home.
只需要在导航中使用条形图和其他页面,但不要使用foo或home。
The homepage has an icon on it that the other pages wont, denoting the root page I guess.
主页上有一个图标,其他页面不会,表示我猜的根页面。
#3
0
The page with the lowest-numbered tree_id in the cms_page table is the home page. This will normally be the first page that you created. If you want to make a different page your home page, you can manually change the tree_id values in your database (but unfortunately not by using the admin.)
cms_page表中编号最小的tree_id的页面是主页。这通常是您创建的第一个页面。如果要在主页上创建不同的页面,可以手动更改数据库中的tree_id值(但遗憾的是不能使用admin。)
#1
3
The easiest way, instead of creating a page that redirect is to just use django's redirect generic view.
最简单的方法,而不是创建一个重定向页面只是使用django的重定向通用视图。
set it in your top level urls.py
将它设置在您的*urls.py中
url(r'^$', RedirectView.as_view(url='/home/')),
and of course add the from django.views.generic.base import RedirectView
import at the beginning and you should be all set.
当然,在开头添加django.views.generic.base导入RedirectView导入,你应该全部设置。
('^$'
only catches the root url and the RedirectView redirect wherever you want. I was a bit unsure about using it myself, but I saw a lot of major websites doing a redirect when you get on to their site...)
('^ $'只捕获根网址和RedirectView重定向,无论你想要什么。我有点不确定自己使用它,但我看到很多主要网站在你进入他们的网站时进行重定向......)
#2
1
The first page you make seems to be the home page, simply add other root pages as needed and enable navigation on them. This is what i have done.
您创建的第一个页面似乎是主页,只需根据需要添加其他根页面并启用它们的导航。这就是我所做的。
Our first page was test, and then some child pages. in the admin page you can click and drag the pages around to change the child/parent order. we renames test to home and shifted the child pages to another root page.
我们的第一页是测试,然后是一些子页面。在管理页面中,您可以单击并拖动页面以更改子/父订单。我们将test重命名为home并将子页面移动到另一个根页面。
You can also override the default menu by make a template in menu/menu.html In there you could override the order by adding in some if statements. You could also hardcode it in your base.html having the menu something like: <ul id=menu> <li><a href="/foo/>foo></a></li> <li><a href="/">Home</a></li> {% show_menu %} <ul>
您还可以通过在menu / menu.html中创建模板来覆盖默认菜单。在那里,您可以通过添加一些if语句来覆盖订单。您也可以在base.html中对其进行硬编码,其菜单类似于:
And just have bar and the other pages you wanted in the navigation but not foo or home.
只需要在导航中使用条形图和其他页面,但不要使用foo或home。
The homepage has an icon on it that the other pages wont, denoting the root page I guess.
主页上有一个图标,其他页面不会,表示我猜的根页面。
#3
0
The page with the lowest-numbered tree_id in the cms_page table is the home page. This will normally be the first page that you created. If you want to make a different page your home page, you can manually change the tree_id values in your database (but unfortunately not by using the admin.)
cms_page表中编号最小的tree_id的页面是主页。这通常是您创建的第一个页面。如果要在主页上创建不同的页面,可以手动更改数据库中的tree_id值(但遗憾的是不能使用admin。)