Priority Page Mod for Links SQL 1.11
This Mod allows you to do several things:- Set priority values for links
- Sort links in order of highest priority
- Create a separate page for priority links similar to the What's Cool page
Name: Priority
Type: INT
Length: 3
Max: 3
Not Null: Yes
Default: 0
Validation: ^\d+$
2. In Links.pm, I have changed my build_sort_order's to:
$LINKS{build_sort_order_category} = "Priority DESC,isNew,Title";
$LINKS{build_sort_order_new} = "Priority DESC,Title,Add_Date";
$LINKS{build_sort_order_cool} = "Priority DESC,Title";
$LINKS{build_sort_order_search} = "isNew,Title,isPopular";
I prefer not to sort Cool links at the top of the list, as it makes the sort order less intuitive. You can leave it in if you wish. You can further set the Priority links apart from the rest by adding something like the following ahead of the HREF tag in your link.html template:
<%if Priority < '1'%>
<IMG SRC="/images/priority.gif" ALT="Priority <%Priority%>">
<%endif%>
<%if Priority > '0'%>
<IMG SRC="/images/no_priority.gif" ALT="Priority <%Priority%>">
<%endif%>
That will place an image of your choice next to any link with a Priority value greater than zero, i.e. not the default.
3. To create the Priority page (see this page for an example), follow these steps:
3a. Add &build_priority_page(); to sub build_all near the top of nph-build.cgi.
3b. Place the following subroutine in nph-build.cgi:
That will pull every link with a Priority value of 10 or greater into the Priority page. You can set the minimum value (I chose 10 because I have some sample Priority links with values of 1 that I don't want included in the page) to something different by modifying the line, Links.Priority > '9'. I have chosen to build the Priority page within the Cool directory, but you can add a build_priority_path to Links.pm if you prefer. (This might actually make the last step with page.cgi the easiest.)
3c. In HTML_Templates.pm, add &site_html_priority to @EXPORT near the top.
3d. Place the following subroutine in HTML_Templates.pm:
3e. Lastly, create a template named priority.html and place the <%link_results%> tag somewhere in it. Format the template to the look of your site and place it in the templates directory.
4. If you want, you can also add the Priority page to the dynamic page.cgi.
4a. In page.cgi, add the following subroutine:
4b. How you choose to call the Priority subroutine in page.cgi is up to you, but here is a discussion outlining the process.