Support Forum
Yellow Swordfish said
The quickest and easiest way to confine your sort change to a single forum would be:add_filter('sph_forumview_query', 'my_sort_function'); function my_sort_function($sqlObj) { global $sfvars; if($sfvars['forumid'] == XX) { $sqlObj->orderby = SFTOPICS . '.topic_name ASC'; } return $sqlObj; }Where XX is the forum ID you want to effect.
Hi SP-team,
I also do have some users who want to have influence in sorting posts preferably as user profile option. Mainly, it is reverse sorting by date - oldest first. I could use the code sample with variation of sorting parameter Is there any document describing this? And how can I find out the forum ID?
"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)
Not documented as such - no. But for posts, a similar type approach could be made. The filter to use would be 'sph_topicview_query' and the sql query would be against the SFPOSTS table using the post_id as the sort column.
You can find the forum ID in the forum listing in the forum admin.
Not sure how you would make it a user option though. Although you may be able to do this with a custom profile field.
YELLOW
SWORDFISH
|
Yes, this would be the way to do it. I'll make it a radio button.
After browsing through forum and documents, I only found this explaining how to read user profile data by programm.
I assume that this is outdated for V5.
What is the V5 name of the function ? Did not find anything searching for 'sp_profile_get_data' or similar.
I guess the array is similar ? Anyhow, if I knew the function, I can get it printed via wp_mail.
"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)
Yes the old wiki only goes up to V4 I am afraid.
So - are you after the user data? If you go to the forum admin > Toolbox > Data Inspector and turn on the option to display spThisUser it will display it for you when you run the forum. You will be the only user to get this display. This will show you the data object available for the current user. It will include any custom profile fields.
YELLOW
SWORDFISH
|
Sorry, I was not clear enough :
I am after the replacement for the function
$profile = sfc_get_profile_data( $userid )
What is the new name for V5? I need it for my php code.
Thanks for the hint to the data inspector. I will need it, too.
"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)
if you want to specify the user, it would be:
$thisUser = sp_get_user($userid);
where $userid contained the user id of the user... if you are on a profile page, you could try:
sp_SetupUserProfileData($userid);
which would actually populate the global variable $spProfileUser...
Visit Cruise Talk Central and Mr Papa's World
Thanks a lot guys for your really excellent support.
I have implemented it now as a custom profile checkbox field where user can individually choose to sort posts in 'reverse' order - meaning oldest post first. And it works like a charm!
Hope they are happy now! Well, at least for a while!
Here is my piece of code in spFunctions.php of my SP-Theme:
function my_sort_function($sqlObj) { global $sfvars, $spThisUser; // $test = $spThisUser->sortierealtestenpostnachoben; if($spThisUser->sortierealtestenpostnachoben) { $sqlObj->orderby = SFPOSTS . '.post_date ASC'; } return $sqlObj; }
where 'sortierealtestenpostnachoben' is the slug name of the custom profile checkbox.
"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)
Well, we have around 225 users in our small community of which 3 have requested to sort the 'oldest on top' way.
Seems that 'most recent on top' is kinda German standard (because of scrolling reasons) and it is the same in many other blogs I know and use.
Ok, ok, we also drive on the right hand side of the road - strange enough!
De gustibus et coloribus non est disputandum!
"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)
1 Guest(s)