Setting up a home page on a Pyplate site

I was recently asked how to set up a home page on a Pyplate web site. You need to do two things to make this work:
1. Create a new layout in the Site Settings field in the Admin area,
2. Edit the database record for page /main.html to use the new layout when this page is served.

To add a new layout, go to the Admin Area’s Site Settings page, and look for the post layout formatting code. It should look something like this, depending on which version of Pyplate you’re using:

 if layout == "post_layout":
 return post_layout.format(
 banner=pyplate.getFile(pyplate.getCMSRoot() + "/template/banner.html"),
 navbar=pyplate.getFile(pyplate.getCMSRoot() + "/template/navbar.html"),
# navbar=pyplate.get_navbar(dbase),
 banner_ad=pyplate.getFile(pyplate.getCMSRoot() + "/template/bananapi_responsive.html"),
 sidebar=sidebar_str,
# sharing=pyplate.get_sharing_template(),
 sharing=pyplate.get_sharing_buttons(path, page.title,page.description),
 breadcrumbs=pyplate.get_breadcrumbs(dbase, page.posts[0]),
 posts=post_str,
 section_menu=pyplate.get_category_menu(dbase, page.category, True, "More from this category:"),
 comments=pyplate.get_comment_template(),
 footer=pyplate.getFile(pyplate.getCMSRoot() + "/template/footer.html"))

Copy that code and paste it directly below the post_layout code. On the first line of th enew block, change post_layout to homepage_layout

#
# Copy the post_layout and change the layout string to homepage_layout
#
 if layout == "homepage_layout":
 return post_layout.format(
 banner=pyplate.getFile(pyplate.getCMSRoot() + "/template/banner.html"),
 navbar=pyplate.getFile(pyplate.getCMSRoot() + "/template/navbar.html"),
# navbar=pyplate.get_navbar(dbase),
 banner_ad=pyplate.getFile(pyplate.getCMSRoot() + "/template/bananapi_responsive.html"),
 sidebar=sidebar_str,
# sharing=pyplate.get_sharing_template(),
 sharing=pyplate.get_sharing_buttons(path, page.title,page.description),
 breadcrumbs=pyplate.get_breadcrumbs(dbase, page.posts[0]),
#
# Instead of using the post_str variable to fill the posts field, 
# use this line 
#
 posts=pyplate.getPost(pyplate.getCMSRoot() + "/content/main.html", "/content/main.html", ),

 section_menu=pyplate.get_category_menu(dbase, page.category, True, "More from this category:"),
 comments=pyplate.get_comment_template(),
 footer=pyplate.getFile(pyplate.getCMSRoot() + "/template/footer.html"))

Next, set the layout field to homepage_layout in the database.  You need to edit the layout field for /main.html. If you’re using a newer version of Pyplate with imort/export control in the Admin Area, then you can just export the database. Open /usr/share/pyplate/database/postindex.xml, and look for the record that contains main.html. Change the layout field to look like this:

<layout>homepage_layout</layout>

Click the import button to import the changes into the database. Then restart your server.

If you’re using an earlier version of Pyplate with no import/export buttons, you need to copy the database from /usr/share/pyplate/database/pyplate.db to a PC. Then you can install Sqlite Studio to edit the database: http://sqlitestudio.pl/. Copy the updated file back to your server and restart it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s