MAXdev
How To Create A Front Page Using pnHome
Seb Hascoet

We have received many requests in the forum about people wanting to have a similar frontpage as MAXdev by using several blocks. The secret lies in a small module that most MDP users ignore: pnHome.

pnHome is composed of 3 files:

The only file worth an interest from us is pnuser.php. However, if you open this file you will see that it contains very little code:

function pnhome_user_main()
{
$ModName = basename(dirname(__FILE__));
$output = new pnHTML();

if (!pnSecAuthAction(0, 'pnHome::', '::', ACCESS_READ)) {
$output->Text(_BADAUTHKEY);
return $output->GetOutput();
}

$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Text('Anything you want here, or leave it blank for nothing');
$output->SetInputMode(_PNH_PARSEINPUT);
return $output->GetOutput();

}

Unless you know how to develops blocks and modules on MDPro, this is going to be of little help for most of us. The way around it is to use Autotheme and some blocks.

For our example, we are going to create a page similar to the one on the MAXdev website but simplified:

The first "block" ("About MDPro") will be for us a short text introducing your website and written in HTML. The second part is a block showing the "10 latest stories published".

Let's start.

1. Ok, this step is not essential and you can skip it, but I would recommend to copy your pnHome folder and rename it into something else (i.e. "frontpage") so that if you want to create several pages using pnHome, you'll always have the original to base them on. Now when you have renamed your folder into "frontpage", you will have to change the occurrences of pnHome inside the file frontpage/pnuser.php:

line 17
Change from
function pnhome_user_main()
to
function frontpage_user_main()

line 22
Change from
if (!pnSecAuthAction(0, 'pnHome::', '::', ACCESS_READ)) {
to
if (!pnSecAuthAction(0, 'frontpage::', '::', ACCESS_READ)) {

While you are in this file, you can also delete the following line (otherwise it will be displayed on your frontpage):

$output->Text('Anything you want here, or leave it blank for nothing');

2. Go to your site administration and initialize / activate the module frontpage.

3. Go to you site administration / Autothemes / Autothemes / YOURTHEMENAME / Autoblocks.
By default, you should already have a name for your different areas (i.e. Area7). Just make sure that you HAVE a name for at least 2 areas. In our example we will use Area8 and Area9 in the following set up:

NOTE: You can change the name and instead of having "Area9" you can have a more descriptive name (i.e. laststories).

4. Create an HTML template for your frontpage and call it "frontpage.html". A good way to start with is to use your default theme.html in your theme folder. Copy it and rename it, then customize it to suit your needs (ie remove the AT command ­). Please be aware that you need to KEEP the AT Command otherwise you theme will not work.
Also, don't forget to add the commands for your areas: and where you want your blocks to appear.

5. Create an HTML template for your blocks. If you use a different template for each block, create one template per block. In our case, we will use the same and it's called "area.html". Again, a good way to start is to use one of your original block templates as a base.

6. Once you are happy with your templates, go to your site administration / Autothemes / Autothemes / YOURTHEMENAME / custom modules.

7. Select a new custom module (i.e. "frontpage") and click "Add".

8. Edit this custom module by entering frontpage.html as your page template, select your template area.html for your blocks 8 and 9 and choose Yes to display these blocks:


9. Go to your site administration / Blocks and create the new blocks you want for your frontpage. In our example, it is blocks/HTML and the Blocks/Story Titles.
In the position dropdown menu, don't forget to select their corresponding areas.

10. Go to your site administration / Settings and choose your module "frontpage" as start page (instead of news).

11. Go back to your site administration / Autothemes / Autothemes / YOURTHEMENAME / custom modules and edit the module "*Homepage" to the same settings as for the module "frontpage" (see pic above). Save.

12. Done! You should now have your 2 blocks displayed on your homepage.

You can obviously make much a better and complex frontpage. Now that you understand how to use pnHome and the areas of Autotheme, your imagination is the only limit!

NOTE: I used some screenshots of the MAXdev site for teaching purpose only and the screenshots has been altered to simplify the procedure. There are many different ways to achieve the same results as the MAXdev website and the procedure detailled above is only ONE of them.

NOTE2: If you have trouble to create HTML templates for Autotheme (frontpage.html and area.html), I recommend that you read the excellent tutorial on the AT website:
Autotheme Tutorial.

NOTE3: This tutorial is based on my own limited experience of Autotheme so it may not be perfect. It worked for me though. If you have another method quicker or more efficient, please share it with the community and/or pm me via maxdev.com so I can edit this tutorial. Many thanks!

 

 

Tutorial created by Seb Hascoet
02/28/2005