Configure the Home Page

With a fresh installation of Onpub, the first article you create (Article 1) in the management interface automatically becomes the home page.

The Onpub home page Article is different from other Onpub Articles in that the Title is not automatically displayed on the page, only the Article's Content field is. This is so you can have full control of the layout of the home page of your Onpub-powered website.

The sections below describe the various configuration options you can use to tweak the look and feel of your Onpub home page.

Configure the Home Page Article ID

If you don't want to use the default of Article ID 1 as your home page, you can easily re-configure this by adding the following frontend config option to your onpub_conf_local.php file:

<?php

// onpub_conf_local.php file

$onpub_disp_article = <ID of home page Article>;

// etc...

?>

Replace <ID of home page Article> in the above line of code with the actual Article ID of the desired home page article and save your onpub_conf_local.php file. Now reload the home page in your browser and it will display the content from the Article ID you specified.

Configure the News Section

Once you have more than 1 Article in your database, by default the News section will be generated on the home page, in addition to displaying the home page Article itself. The News section is configurable in several different ways, all of which are documented below.

Hide the News

If you don't want the News to be displayed at all on your Onpub home page, add the following line to your onpub_conf_local.php file:

<?php

// onpub_conf_local.php file

$onpub_disp_updates = false;

// etc...

?>

The above frontend config option, will automatically hide the News section from the home page. This will cause the configured home page Article to automatically take up the whole width of the home page. If you decide that you want to show the News section again, set the $onpub_disp_updates option back to its default value of true. Or simply remove the above config option from your onpub_conf_local.php file and the default option will automatically take effect again.

Specify the Number of Articles to Display under News

You can easily configure up to how many of your latest articles you want to display under the News section. The default is 5 of the most recent created articles. If you want to change this, add the following configuration option to your onpub_conf_local.php file:

<?php

// onpub_conf_local.php file

$onpub_disp_updates_num = 10;

// etc...

?>

If you use the above example, your News section will now display up to 10 of your latest articles. Articles only display under News if they are visible within one or more of your publicly visible Onpub Sections. Also, the home page Article itself will never be displayed under News. You can replace 10 with any valid positive number to control how many articles you want to output under News.

Change the News Heading

By default, the heading of the News section on the home page is literally called News. If you wanted to change this label to something else entirely, follow the steps below:

  1. Create a file called OnpubFrontendCustom.php within your onpub/local/ directory.
  2. Within your OnpubFrontendCustom.php file, paste in the following code:

<?php

class OnpubFrontendCustom extends OnpubFrontend

{
  function __construct()
  {
    parent::__construct();
    $this->labelUpdates = 'Latest Updates';
  }
}

?>

The above is an example of modifying the Onpub frontend layout via PHP object extension. The line $this->labelUpdates = 'Latest Updates'; is what will change the News heading from News to Latest Updates. You can change the 'Latest Updates' string to whatever you want the heading of your News section to be.