Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Topics order in forum, seems not to work
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 14, 2016 - 4:46 pm

The code is good - I tested it out, How did you copy and paste it? did you use the 'raw code' button and copy/paste the result from the popup window?

andy-signature.png
YELLOW
SWORDFISH
Avatar
Giovanna
Nijmegen - NL
Member
sp_UserOfflineSmall Offline
Mar 14, 2016 - 6:59 pm

the code looks exactly like yours plus the php tags and some comments I added, here you are:

<?php
# --------------------------------------------------------------------------------------
#
# Simple:Press trick to order the topis in the forums:
# 5: Pesate settimanali
# 6: Diario Alimentare
# 17: Diario: commenti e domande
# 18: Pesate: commenti e domande
# in ascending order for the creation date.
# This file has been created by hand, named sp-user-functions.php and
# put into the wp-content folder of mspforum.
# The whole thread on the support forum is at this link:
# https://simple-press.com/suppo.....k/#p159916
#
# --------------------------------------------------------------------------------------
add_filter('sph_forumview_query', 'my_topic_sort', 1, 2);
function my_topic_sort($db, $data) {
$fids = '&5&6&17&18&';
if ( strpos( $fids, '&'.$data->forumId.'&' )) {
$db->orderby = 'topic_pinned DESC, spf_sftopics.topic_id DESC';
}
return $db;
}

?>

I had to add it directly under the wp-content folder right? That sounded a little strange that's why I ask again...

My forum (in Italian) is: MsPforum

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Mar 14, 2016 - 7:09 pm

I've never used sp-user-functions.php, but I think it's contents just get added to the regular functions file meaning you shouldn't need the PHP tags.. It's future proof as it won't be overwritten.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Mar 14, 2016 - 10:04 pm

Andy's question about how you copied it still applies... if you copied the text directly in the post, you probably got some invalid characters...  you must view the raw code and copy it from the popup to ensure you dont get the invalid chars..

Avatar
Giovanna
Nijmegen - NL
Member
sp_UserOfflineSmall Offline
Mar 15, 2016 - 2:42 am

I don't understand what you mean with "raw code". I used notepad and edited the code, which I then copied and pasted here. Can you please explain? Thanks and goodmorning!smile

My forum (in Italian) is: MsPforum

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 15, 2016 - 4:03 am

Let's just step back. IF after a code change or addition, something stops displaying completely then that is indicative of a coding error. So it is always vital to ensure that everything is totally correct.

Pasting code into a forum post may look like it is correct but actually the display engine has stripped all coding specific components and replaced them with html entities. If you do not know hat they are then it doesn't matter. It just means that what might look like good code probably is not if simply copied and pasted.

Ans this is why we use our syntax highlighter plugin to pass code to users as this does ensure that the code is not converted by the display engine. 

If you go back to the code I gave you - post 7 I believe - then you will see above it a 'war code' button. Click on that and you will get a popup window with the actual, unconverted code, That is what you need to copy into your clipboard before placing it into the new php file. And also you MUST ensure that the editor you use is in plain text mode.

And finally - Ike was wrong I am afraid. You DO need to enclose the code in php tags. Make sure that there are no empty lines either side of the tags. The opening tag must be on l;ine 1 and the closing tag must be on the last line with no empty space below it.

And finally, finally ! - yes - the file just goes into the wp-content folder. It is a special file that we check for that allows people to have a little bit of custom code without having to make a child theme - although child themes are the better and recommended route.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Giovanna
Nijmegen - NL
Member
sp_UserOfflineSmall Offline
Mar 15, 2016 - 4:36 am

ok got it, I did not know about this "war code", I like it laugh Going to try right now...

My forum (in Italian) is: MsPforum

Avatar
Giovanna
Nijmegen - NL
Member
sp_UserOfflineSmall Offline
Mar 15, 2016 - 4:40 am

it does not work, I made the file back from scratch, no comment lines, only the raw code and the php tags beggining and end cry

My forum (in Italian) is: MsPforum

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 15, 2016 - 4:58 am

In what way does it 'not work'?
And if you mean the whole thing bombs then email me your file (support at simple-press dot com)

andy-signature.png
YELLOW
SWORDFISH
Avatar
Giovanna
Nijmegen - NL
Member
sp_UserOfflineSmall Offline
Mar 15, 2016 - 5:17 am

I mean that the list with all the topic disappears (but the pages numbers at the bottom are still displayed): I will send you the file in 5 minutes!

My forum (in Italian) is: MsPforum

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 617
Members: 17359
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10125
Posts: 79620