Back To Coranto Examples

Creating  individual user pages with an index file using Coranto and Maginot.

Creating Individual User Pages With Coranto And Maginot.

Using Maginot Sliced & Sliced Index templates it's possible to automatically create a separate page for each user.  www.railroadtycoon.info uses this on the User Pages to create an index linking to each users page, along with  their individual page.  In addition, each users submissions are automatically added to the Coranto includes for the main website.

 

There are four Sliced Profiles used to create the includes for each users page, one Sliced profile to create the page for each user and a Sliced Index page to create the overall user index.

 

To keep things simple I'll simply look at one of the content sliced profiles and the profile/index used to create the index page.

 

Lets look at the settings for the user_news profile.  We'll only look at the essential stuff, the rest should either be left at the default or self explanatory.

 

user_news

Main Profile Settings

File Path:

/home/railroadtycoon/public_html/users

At the moment all the user includes are kept in one folder.  With a larger site it would make sense to use <Field: User> to split them into individual user directories.

Categories:

News

We only want the users news items.

News Style:

Default Style

We don't really need to change the layout of the news items for the user pages.

Maginot Sliced Profile Settings

Slice Field:

User

This is the important bit!  Also be aware that if you go and edit your profile the Slice Field will default back to newsid so remember to check it!!!

File Extension:

news

This is also important, this means we end up with an include file of <User>.news for example:

Webmaster.news

HawkDawg.news

etc.

Maximum File Name Length:

128

Well, we might get someone with a long name!

 

So now we have Webmaster.news and HawkDawg.news created in the /users part of the website.  But how do we get them into a page like Webmaster.html?  For this we use another sliced profile but this time with a template!

 

user_page

Main Profile Settings

File Path:

/home/railroadtycoon/public_html/users

Same place as the includes

Categories:

(All Categories)

We want to create an index page for the user if they've submitted anything.

News Style:

Default Style

Doesn't matter as we're not actually interested in any of the actual items, we'll use our previous profile includes to do the work.

Advanced Profile Settings

HTML Template

user.tmpl

We'll look at this in more detail next!

Sort Order

Alphabetical (By Subject)

Can't remember exactly why I chose this order, shouldn't be relevant.

Maginot Sliced Profile Settings

Slice Field:

User

This is the important bit!  Also be aware that if you go and edit your profile the Slice Field will default back to newsid so remember to check it!!!

File Extension:

html

This is also important, this means we end up with an include file of <User>.html for example:

Webmaster.html

HawkDawg.html

etc.

Maximum File Name Length:

128

Well, we might get someone with a long name!

 

The user_page profile users a template (in this case user.tmpl) to create the web page.  Unlike normal Coranto templates we're not interested in the <Field: Content> tag as we're going to be using multiple content from our includes.  So the relevant template could look something like this:

 

<html>
<head>
<!--#config errmsg="" -->
</head>
<body>
<h1><Field: SliceValue></h1>
<p>Maps</p>
<!--#include virtual="<Field: SliceValue>.maps" -->
<p>News</p>
<!--#include virtual="<Field: SliceValue>.news" -->
<p>Gallery</p>
<!--#include virtual="<Field: SliceValue>.gallery" -->
</body>
</html>

 

In reality the template used was considerably more complicated, and if you're really masochistic you can find it here.

 

So, now we've got Webmaster.html and HawkDawg.html sitting in the /users folder of the site.  Now, we COULD manually edit and create the index.html file for that folder listing the users (which may be necessary for your site!) but I'm lazy and allow guest registration, so I want Coranto to take care of creating the index.html file for me.  This time we're going to use a Maginot Sliced Index profile to create user_index.inc as an include for the index.html page.

 

user_index

Main Profile Settings

File Path:

/home/railroadtycoon/public_html/users

Surprise Surprise! :)

Directory Url:

http://www.railroadtycoon.info/users

Full URL to the folder.

Base Url:

http://www.railroadtycoon.info/users

For completeness

Text File:

user_index.inc

Standard include file.

Categories:

(All Categories)

Again we want everything.

News Style:

user_index

This is a very simple style that generates the link, it looks like this:

<h2>
<a href="http://www.railroadtycoon.info/users/<Field: LinkName>">
<Field: SliceValue>
</a>
</h2>

I separated the lines for clarity.

Advanced Profile Settings

Slice Profile

user_page

We're creating the list based on which user_pages were created.

Sliced Index Sorting

Alphabetical

May as well make it easy for people to find their name :)

 

And that's just about it, the users/index.html page contains a standard include to use the user_index.inc file

<!--#include virtual="user_index.inc" -->

 

And that's it... Individual user pages and a list of users, all generated automagically by Coranto.

 

[Home] [Services] [Clients] [Coranto]