Sorry if this has been posted before in the past, I could not find it, so I made the changes and thought someone else might be able to use it. It's the first mod of any length at all I've posted, so let me know if I should be posting them in a different way, or if the instructions are not clear. --Lloyd
Display your categories in an arbitrary order on your home page in Links 2.0
-----------------------------------------------------------------------------
By: Lloyd Sommerer: lloyd@gatheringspot.com
Example: http://churchsite.gatheringspot.com/links2/
time to make sure you are not breaking them as you
make these changes. In most cases here you can see
just what was changed and make any needed adjustments.The Modifications...
---------------------------
**************************************
* In links.cfg *
**************************************FIND THE FOLLOWING LINE
ADD THESE 3 LINES ***BEFORE*** IT
# the categories by when displaying them on your home page.
# [0=ID] [1=Name] [X=Your New Field] (you have to replace "X" with a number)
$cat_sort_field = 0;
**************************************
* In site_html_templates.pl *
**************************************FIND THE FOLLOWING LINE
AND REPLACE IT WITH THESE 2 LINES
foreach $subcat (sort byfield @subcat) {
**************************************
* in category.def *
**************************************NOTE: You can ignore this section if you are going to use one of the fields already
present in the category database for your sort order (I use the ID).
FIND THIS SECTION (IT'S AT THE TOP)
# Database Definition: CATEGORIES
# --------------------------------------------------------
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 500, 0, '', ''],
Related => [3, 'alpha', 0, 255, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 75, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 75, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', '']
);PLACE THIS LINE UNDER THE LAST ENTRY IN THE LIST JUST BEFORE THE ");"
NOTE: The field id, in this case 8 should be changed to reflect the fields position
in your database. Don't forget to place a comma at the end of the entry on the line
above Category Sort.
NOTE: If you added the field above, then you also need to edit your categories.db file.
The easiest (depending on the size of your database) way to do this is to open
categories.db in a text editor and add a "|" to the end of each line. If you'd like,
you could also set your display order at this time by entering "|1", "|2", "|3" and
so forth (lower numbered categories are displayed first).
END OF MOD
FAQ
----
Q: Did you copy the format of this mod from John Gotze?
A: Yeah, pretty much. Don't tell him.
Q: My categories are sorted by string ("12" > "20") even though I'm trying to sort by a numerical field. What should I do?
A: Change "cmp" to "<=>" in the modification you made to site_html_templates.pl above.
Q: How can I sort in the opposite order (Z..A or 100..0)?
A: Switch "$a" and "$b" in the modification you made to site_html_templates.pl above.
Q: What do I do if I have another question?
A: Post it as a reply to this message and I'm sure someone will answer it forthwith.
Q:How do you modify the order of the subcategories on your home page if you are using the yahoo sub cat mod?
A:In site_html_templates.pl replace this line:
foreach (sort @{$subcategories{$subcat}}) {
with this line:
foreach (sort byfield @{$subcategories{$subcat}}) {
Display your categories in an arbitrary order on your home page in Links 2.0
-----------------------------------------------------------------------------
By: Lloyd Sommerer: lloyd@gatheringspot.com
Example: http://churchsite.gatheringspot.com/links2/
Code:
NOTE: If you have made other modifications, please take the time to make sure you are not breaking them as you
make these changes. In most cases here you can see
just what was changed and make any needed adjustments.
---------------------------
Code:
**************************************
* In links.cfg *
**************************************
Code:
# Date RoutinesADD THESE 3 LINES ***BEFORE*** IT
Code:
# Category Sort Field, the position in your category database of the field to sort # the categories by when displaying them on your home page.
# [0=ID] [1=Name] [X=Your New Field] (you have to replace "X" with a number)
$cat_sort_field = 0;
Code:
**************************************
* In site_html_templates.pl *
**************************************
Code:
foreach $subcat (sort @subcat) {Code:
sub byfield { $category{$a}[$cat_sort_field] cmp $category{$b}[$cat_sort_field] }; foreach $subcat (sort byfield @subcat) {
Code:
**************************************
* in category.def *
**************************************
present in the category database for your sort order (I use the ID).
FIND THIS SECTION (IT'S AT THE TOP)
Code:
# Database Definition: CATEGORIES
# --------------------------------------------------------
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 500, 0, '', ''],
Related => [3, 'alpha', 0, 255, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 75, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 75, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', '']
);
Code:
'Category Sort' => [8, 'numer' ,5, 8, 0, '', '']in your database. Don't forget to place a comma at the end of the entry on the line
above Category Sort.
NOTE: If you added the field above, then you also need to edit your categories.db file.
The easiest (depending on the size of your database) way to do this is to open
categories.db in a text editor and add a "|" to the end of each line. If you'd like,
you could also set your display order at this time by entering "|1", "|2", "|3" and
so forth (lower numbered categories are displayed first).
END OF MOD
FAQ
----
Q: Did you copy the format of this mod from John Gotze?
A: Yeah, pretty much. Don't tell him.
Q: My categories are sorted by string ("12" > "20") even though I'm trying to sort by a numerical field. What should I do?
A: Change "cmp" to "<=>" in the modification you made to site_html_templates.pl above.
Q: How can I sort in the opposite order (Z..A or 100..0)?
A: Switch "$a" and "$b" in the modification you made to site_html_templates.pl above.
Q: What do I do if I have another question?
A: Post it as a reply to this message and I'm sure someone will answer it forthwith.
Q:How do you modify the order of the subcategories on your home page if you are using the yahoo sub cat mod?
A:In site_html_templates.pl replace this line:
foreach (sort @{$subcategories{$subcat}}) {
with this line:
foreach (sort byfield @{$subcategories{$subcat}}) {