[hot] [route-fix] get_next
This commit is contained in:
parent
fff599b4dc
commit
231bbc242e
2 changed files with 7 additions and 4 deletions
|
|
@ -64,11 +64,11 @@ def render_blocks(context):
|
|||
out["content"] = out["content"].replace("{index}", html)
|
||||
|
||||
if "{next}" in out.get("content", ""):
|
||||
next_item = context.get_next()
|
||||
next_item = context.doc.get_next()
|
||||
if next_item:
|
||||
if next_item.name[0]!="/": next_item.name = "/" + next_item.name
|
||||
html = '''<p><br><a href="{name}" class="btn btn-primary">
|
||||
{page_title} <i class="icon-chevron-right"></i></a>
|
||||
{title} <i class="icon-chevron-right"></i></a>
|
||||
</p>'''.format(**next_item)
|
||||
out["content"] = out["content"].replace("{next}", html)
|
||||
|
||||
|
|
|
|||
|
|
@ -149,6 +149,10 @@ class WebsiteGenerator(Document):
|
|||
parents.reverse()
|
||||
return parents
|
||||
|
||||
def get_parent(self):
|
||||
if hasattr(self, "parent_website_route_field"):
|
||||
return self.get(self.parent_website_route_field)
|
||||
|
||||
def get_children(self):
|
||||
if self.get_route()==get_home_page():
|
||||
return frappe.db.sql("""select url as name, label as page_title,
|
||||
|
|
@ -183,8 +187,7 @@ class WebsiteGenerator(Document):
|
|||
def get_next(self):
|
||||
if self.meta.get_field("parent_website_route") and self.parent_website_route:
|
||||
route = self.get_route()
|
||||
siblings = frappe.get_doc(self.doctype,
|
||||
self.parent_website_route).get_children()
|
||||
siblings = frappe.get_doc(self.doctype, self.get_parent()).get_children()
|
||||
for i, r in enumerate(siblings):
|
||||
if i < len(siblings) - 1:
|
||||
if route==r.name:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue