Ah, I've edited my entry while you replied
I've now tested some mixtures and it always seems to work. I'd rather not make an extra plugin. The way it is now, all one needs to do is modifying the entryproperties plugin.
The only "downside" is that it interprets the value as a string and sorts accordingly.
Here is the guide (V1.0):
1. Install the categorytemplate plugin ("Properties/Templates of categories"), it gives each category a field where you can enter your sorting value.
2. Install the entryproperties plugin ("Extended properties for entries"). You will need to edit this.
3. Open the serendipity_event_entryproperties.php, which resides inside plugins/ serendipity_event_entryproperties, with an editor of your choice.
4. Go to the "introspect(&$propbag)" function and change the configuration add to the following:
Code: Select all
$propbag->add('configuration', array('sorting_priority', 'cache', 'sequence', 'use_groups', 'use_users', 'use_ext_joins', 'default_read', 'customfields'));
5. Go to the "introspect_config_item($name, &$propbag)" function below and insert the following case (doesn't matter where):
Code: Select all
case 'sorting_priority':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_PRIORITY);
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_PRIORITY_DESC);
$propbag->add('default', '0');
break;
6. Go to the "getSupportedProperties()" function and change the line that sets the supported properties to this one:
Code: Select all
$supported_properties = array('sorting_priority', 'is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_frontpage', 'hiderss', 'entrypassword');
7. Go to the "showBackend($element, etc." function and change the function header by inserting "$sorting_priority" at the 3rd place so that it looks like this:
Code: Select all
function showBackend($element, $eventData, $sorting_priority, $is_sticky, etc.
7.1 In the same function, insert the following case:
Code: Select all
case 'priority':
?>
<div class="entryproperties_sorting_priority">
<input class="input_textbox" type="text" name="serendipity[properties][sorting_priority]" id="properties_sorting_priority" value="<?php echo $sorting_priority?>"/>
<label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_PRIORITY; ?>" for="properties_sorting_priority"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_PRIORITY_DESC; ?> </label>
</div>
<?php
break;
8. Go to the "event_hook" function.
Now, go to the "backend_display" case and insert the following piece of code
before the fieldset is created:
Code: Select all
if (isset($eventData['properties']['ep_sorting_priority'])) {
$sorting_priority = $eventData['properties']['ep_sorting_priority'];
} elseif (isset($serendipity['POST']['properties']['sorting_priority'])) {
$sorting_priority = $serendipity['POST']['properties']['sorting_priority'];
} else {
$sorting_priority = $this->get_config('sorting_priority', '0');
}
8.1 Replace the foreach loop in the same case with this one (inserted $sorting_priority):
Code: Select all
foreach($elements AS $element) {
$this->showBackend($element, $eventData, $sorting_priority, $is_sticky, $no_frontpage, $hiderss, $access_values, $access, $password, $use_groups, $access_groups, $use_users, $access_users, $more);
}
8.2 Now, go to the "frontend_fetchentry" case in the function and insert the following line
before "$cond = implode("\n", $conds);":
Code: Select all
$conds[] = 'ep_sorting_priority.value AS sorting_priority,';
8.3 In the same case, insert the following LEFT OUTER JOIN where all the other LEFT OUTER JOINS are created. I've inserted it as a first LEFT OUTER JOIN, but I doubt that it matters.
Code: Select all
$joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_sorting_priority
ON (e.id = ep_sorting_priority.entryid AND ep_sorting_priority.property = 'ep_sorting_priority')";
9. Place the following lines in the language file:
Code: Select all
@define('PLUGIN_EVENT_ENTRYPROPERTIES_PRIORITY', 'Sorting priority');
@define('PLUGIN_EVENT_ENTRYPROPERTIES_PRIORITY_DESC', 'This value defines at what place in the entry list this entry is displayed. Needs the "Sort order" in the category to be set to "sorting_priority DESC" or "sorting_priority ASC".');
10. Remember to enable the new priority field in the entryproperties-plugin-configuration.
Also remember to make use of the plugin in the categories, where you want your entries to be custom-sorted. "sorting_priority ASC" will put the lowest priority first.
Important: The query actually interprets the priority_value as a string. That means, if you have the following priorities: 0,300,3,1,400,4, the order will be (if you chose "sorting_priority ASC"): 0,1,3,300,4,400.