Forums
This topic is locked
Building a menu of categories
Posted 12 Nov 2004 00:19:32
1
has voted
12 Nov 2004 00:19:32 Jens Jakobsen posted:
Hi AllI want to build a menu consisting of a list of categories.
The setup should consist of 3 pages:
1: Main menu - a list of all the categories linking to a page that shows only links to articles that refers to the category.
2: A list of articles referring to the category
3: An article
Now I'd like to avoid to build each and every page referring to one category - if I have 10 categories then I'd like to avoid building 10 pages.
I want to be able to build only 3 pages regardless of how many categories I have.
How does one do that in DW 2004 MX???
I've been messing around with the server behaviours (go to detail page/Go to related page) but somehow I keep missing it!
Replies
Replied 12 Nov 2004 01:03:02
12 Nov 2004 01:03:02 Simon Martin replied:
Hi Jens,
First off you need to set up a database. It will need a table for the categories and one for the articles - linking articles to the category table by the category PK. You might also consider also one for users if they're making posts and maybe one for access levels if you want to have different permissions such as Visitor, Author and Admin.
Next to build your main menu you create a recordset. SELECT * FROM tblCategory (or something like that) and then put the text description for the category on the page. From the server behaviours window select repeat region (probably want to let it repeat for every item in your recordset). That will give you a list on the page for each category you have in the database.
Select the category text you have placed on the page and select Go To Detail Page. In the dialogue box make sure your text is shown in the Link, point it at articles.asp (or whatever) for your detail page.
Now you need to pass the ID value for the category, so pass url parameter should be something like catID (something that you know what it is and you can pick up on the next page). Make sure your recordset is selected and in the column select the primary key from tblCategory and click OK
2. articles.asp - you'll need to build a recordset that gets all your article titles and ID's and filter it by the foreign key for category where it = querystring catID (or whatever you set up in the previous dialogue) Now the query will select all records from the articles table where they have the category value that was selected on the main menu.
Now drag the title field from the bindings panel onto the page and apply a repeat region to this; so you will have a dynamic list of all articles for the desired category. Again you'll need to open a detail page. Use the text as the link and this time pass the article ID to the detail page in the url.
3. Build a recordset for the articles filtering on the article ID passed in from the previous page, but this time get all the details you've stored and then simply display them on the page.
Hopefully that makes sense to you.
I'll be online tomorrow if you need
Sharing knowledge saves valuable time!
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
First off you need to set up a database. It will need a table for the categories and one for the articles - linking articles to the category table by the category PK. You might also consider also one for users if they're making posts and maybe one for access levels if you want to have different permissions such as Visitor, Author and Admin.
Next to build your main menu you create a recordset. SELECT * FROM tblCategory (or something like that) and then put the text description for the category on the page. From the server behaviours window select repeat region (probably want to let it repeat for every item in your recordset). That will give you a list on the page for each category you have in the database.
Select the category text you have placed on the page and select Go To Detail Page. In the dialogue box make sure your text is shown in the Link, point it at articles.asp (or whatever) for your detail page.
Now you need to pass the ID value for the category, so pass url parameter should be something like catID (something that you know what it is and you can pick up on the next page). Make sure your recordset is selected and in the column select the primary key from tblCategory and click OK
2. articles.asp - you'll need to build a recordset that gets all your article titles and ID's and filter it by the foreign key for category where it = querystring catID (or whatever you set up in the previous dialogue) Now the query will select all records from the articles table where they have the category value that was selected on the main menu.
Now drag the title field from the bindings panel onto the page and apply a repeat region to this; so you will have a dynamic list of all articles for the desired category. Again you'll need to open a detail page. Use the text as the link and this time pass the article ID to the detail page in the url.
3. Build a recordset for the articles filtering on the article ID passed in from the previous page, but this time get all the details you've stored and then simply display them on the page.
Hopefully that makes sense to you.
I'll be online tomorrow if you need
Sharing knowledge saves valuable time!
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 12 Nov 2004 23:35:21
12 Nov 2004 23:35:21 Jens Jakobsen replied:
Wow that was some answer - let me get back to you - thanks a lot!
Replied 29 Nov 2004 11:22:18
29 Nov 2004 11:22:18 Jens Jakobsen replied:
Hi Simon - hope that you are reading this. I've been messing around with the above mentioned article you wrote and I'm not sure I'm doing it right. Here goes:
The main menu (listing the categories) has been set up correctly. I can see the categories (repeat region).
I have made the link to the detail page - please see the picture below:
<img src="www.fransk-antik.dk/images/category.gif" border=0>
Then (- this is where I'd REALLY appreciate some screen shots) I think I'm doing something wrong with the articles page - see screenshot below:
<img src="www.fransk-antik.dk/images/article.gif" border=0>
I don't think I get what you wrote below:
<pre id=code><font face=courier size=2 id=code>2. articles.asp - you'll need to build a recordset that gets all your article titles
and ID's and filter it by the foreign key for category where it = querystring catID
(or whatever you set up in the previous dialogue)
Now the query will select all records from the articles table where they have
the category value that was selected on the main menu.
</font id=code></pre id=code>
Edited by - fridge on 29 Nov 2004 11:23:59
The main menu (listing the categories) has been set up correctly. I can see the categories (repeat region).
I have made the link to the detail page - please see the picture below:
<img src="www.fransk-antik.dk/images/category.gif" border=0>
Then (- this is where I'd REALLY appreciate some screen shots) I think I'm doing something wrong with the articles page - see screenshot below:
<img src="www.fransk-antik.dk/images/article.gif" border=0>
I don't think I get what you wrote below:
<pre id=code><font face=courier size=2 id=code>2. articles.asp - you'll need to build a recordset that gets all your article titles
and ID's and filter it by the foreign key for category where it = querystring catID
(or whatever you set up in the previous dialogue)
Now the query will select all records from the articles table where they have
the category value that was selected on the main menu.
</font id=code></pre id=code>
Edited by - fridge on 29 Nov 2004 11:23:59
Replied 29 Nov 2004 13:37:07
29 Nov 2004 13:37:07 Simon Martin replied:
The columns selected are those that will be used / displayed on articles.asp, so the primary key for the article and its title.
The filter needs to select the records that have the same category id as selected on the main page. From your screenshot it looks like the filter is selecting the article id that = the category id.
The filter is making the relationship between the 2 tables, you want to
select the id and overskrift
from the article table
where the kategori = katID (i'm assuming kategori is the foreign key)
so you should change the filter so the kategori = URL Parameter katID
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
The filter needs to select the records that have the same category id as selected on the main page. From your screenshot it looks like the filter is selecting the article id that = the category id.
The filter is making the relationship between the 2 tables, you want to
select the id and overskrift
from the article table
where the kategori = katID (i'm assuming kategori is the foreign key)
so you should change the filter so the kategori = URL Parameter katID
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 30 Nov 2004 07:49:43
30 Nov 2004 07:49:43 Jens Jakobsen replied:
Thank you thank you thank you!!!!!!!!
I made it work - this will speed up my future development incredibly!
I made it work - this will speed up my future development incredibly!